@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
|
@@ -4,7 +4,8 @@ import { decodeOoxmlSymbolCharacter } from "../utils/ooxmlSymbol.js";
|
|
|
4
4
|
import { wrapComment, wrapDeletion, wrapInsertion, wrapMoveFrom, wrapMoveTo } from "./annotations.js";
|
|
5
5
|
import { escapeAltText, escapeInline, escapeLinkUrl } from "./escape.js";
|
|
6
6
|
import { registerImage } from "./images.js";
|
|
7
|
-
import { pushWarning } from "./internals.js";
|
|
7
|
+
import { numberNoteReference, pushWarning } from "./internals.js";
|
|
8
|
+
import { compileMarkdownToContent } from "@stll/docx-core";
|
|
8
9
|
//#region src/markdown/renderRuns.ts
|
|
9
10
|
const MARK_DELIMS = {
|
|
10
11
|
bold: "**",
|
|
@@ -32,9 +33,9 @@ function marksFor(run) {
|
|
|
32
33
|
const f = run.formatting;
|
|
33
34
|
if (!f) return [];
|
|
34
35
|
const out = [];
|
|
36
|
+
if (f.strike) out.push("strike");
|
|
35
37
|
if (f.bold) out.push("bold");
|
|
36
38
|
if (f.italic) out.push("italic");
|
|
37
|
-
if (f.strike) out.push("strike");
|
|
38
39
|
const ascii = f.fontFamily?.ascii?.toLowerCase();
|
|
39
40
|
if (ascii && MONOSPACE_FONTS.has(ascii)) out.push("code");
|
|
40
41
|
return out;
|
|
@@ -42,7 +43,7 @@ function marksFor(run) {
|
|
|
42
43
|
function applyMarks(text, marks) {
|
|
43
44
|
if (!text) return text;
|
|
44
45
|
if (marks.includes("code")) {
|
|
45
|
-
const literal = text.replace(/\\(?<char>[\\`*[\]_
|
|
46
|
+
const literal = text.replace(/\\(?<char>[\\`*[\]_<~])/gu, "$<char>");
|
|
46
47
|
let longestRun = 0;
|
|
47
48
|
for (const m of literal.matchAll(/`+/gu)) longestRun = Math.max(longestRun, m[0].length);
|
|
48
49
|
const fence = "`".repeat(longestRun + 1);
|
|
@@ -56,6 +57,133 @@ function applyMarks(text, marks) {
|
|
|
56
57
|
}
|
|
57
58
|
return out;
|
|
58
59
|
}
|
|
60
|
+
const UNKNOWN_NEIGHBORS = {
|
|
61
|
+
before: void 0,
|
|
62
|
+
after: void 0
|
|
63
|
+
};
|
|
64
|
+
const isBlank = (ch) => ch === "" || ch !== void 0 && /\s/u.test(ch);
|
|
65
|
+
/**
|
|
66
|
+
* Which mark wraps a stretch of runs first, outermost first. Strikethrough
|
|
67
|
+
* goes inside emphasis: an emphasis delimiter beside a tilde opens and closes
|
|
68
|
+
* wherever it stands, where the other way round (`~~*`) needs a blank or
|
|
69
|
+
* punctuation outside.
|
|
70
|
+
*/
|
|
71
|
+
const GROUPING_ORDER = [
|
|
72
|
+
"italic",
|
|
73
|
+
"bold",
|
|
74
|
+
"strike"
|
|
75
|
+
];
|
|
76
|
+
/** The stackings tried, in turn, where the reader misreads one. */
|
|
77
|
+
const GROUPING_ORDERS = [GROUPING_ORDER, [
|
|
78
|
+
"bold",
|
|
79
|
+
"italic",
|
|
80
|
+
"strike"
|
|
81
|
+
]];
|
|
82
|
+
/**
|
|
83
|
+
* CommonMark punctuation (Unicode P and S categories) as a delimiter of
|
|
84
|
+
* `mark` meets it. Beside an emphasis delimiter, an asterisk is another
|
|
85
|
+
* delimiter that runs together with it, and a tilde does not let it close
|
|
86
|
+
* (the GFM reader's rule): both count as letters. (Words carry them escaped,
|
|
87
|
+
* as a two-character unit.)
|
|
88
|
+
*/
|
|
89
|
+
const punctuationFor = (mark) => (ch) => {
|
|
90
|
+
if (ch === void 0 || ch === "" || ch === "~") return false;
|
|
91
|
+
if (mark !== "strike" && ch === "*") return false;
|
|
92
|
+
return /[\p{P}\p{S}]/u.test(ch);
|
|
93
|
+
};
|
|
94
|
+
/** One escape pair (`\*`) or one code point of escaped inline text. */
|
|
95
|
+
const INLINE_UNIT = /\\[\s\S]|[\s\S]/gu;
|
|
96
|
+
/**
|
|
97
|
+
* Wrap `inner` in `mark` so a CommonMark reader reads it back. A delimiter
|
|
98
|
+
* opens only before a character that is not blank, and before punctuation
|
|
99
|
+
* only where blank or punctuation precedes it; closing mirrors that. Where
|
|
100
|
+
* the words at an edge would stop a delimiter from opening or closing (a
|
|
101
|
+
* space at the edge, emphasis ending in a full stop right before a letter),
|
|
102
|
+
* those characters are left outside the emphasis rather than written as
|
|
103
|
+
* literal asterisks.
|
|
104
|
+
*/
|
|
105
|
+
function wrapFlanking(inner, mark, { before, after }) {
|
|
106
|
+
const isPunctuation = punctuationFor(mark);
|
|
107
|
+
const opensAfter = (ch) => isBlank(ch) || isPunctuation(ch);
|
|
108
|
+
const units = Array.from(inner.matchAll(INLINE_UNIT), ([unit]) => unit);
|
|
109
|
+
const isPunctuationUnit = (unit) => unit.length === 2 && unit.startsWith("\\") || isPunctuation(unit);
|
|
110
|
+
let start = 0;
|
|
111
|
+
let end = units.length;
|
|
112
|
+
let outside = before;
|
|
113
|
+
for (;;) {
|
|
114
|
+
const unit = units[start];
|
|
115
|
+
if (unit === void 0 || start >= end) break;
|
|
116
|
+
if (!isBlank(unit) && (!isPunctuationUnit(unit) || opensAfter(outside))) break;
|
|
117
|
+
outside = unit.at(-1);
|
|
118
|
+
start++;
|
|
119
|
+
}
|
|
120
|
+
outside = after;
|
|
121
|
+
for (;;) {
|
|
122
|
+
const unit = units[end - 1];
|
|
123
|
+
if (unit === void 0 || end <= start) break;
|
|
124
|
+
if (!isBlank(unit) && (!isPunctuationUnit(unit) || opensAfter(outside))) break;
|
|
125
|
+
outside = unit.at(0);
|
|
126
|
+
end--;
|
|
127
|
+
}
|
|
128
|
+
return units.slice(0, start).join("") + applyMarks(units.slice(start, end).join(""), start < end ? [mark] : []) + units.slice(end).join("");
|
|
129
|
+
}
|
|
130
|
+
/** Paragraph content that writes nothing to the line. */
|
|
131
|
+
const SILENT_MARKERS = /* @__PURE__ */ new Set([
|
|
132
|
+
"bookmarkStart",
|
|
133
|
+
"bookmarkEnd",
|
|
134
|
+
"moveFromRangeStart",
|
|
135
|
+
"moveFromRangeEnd",
|
|
136
|
+
"moveToRangeStart",
|
|
137
|
+
"moveToRangeEnd"
|
|
138
|
+
]);
|
|
139
|
+
/** Comment range markers, which write nothing when comments are stripped. */
|
|
140
|
+
const COMMENT_MARKERS = /* @__PURE__ */ new Set(["commentRangeStart", "commentRangeEnd"]);
|
|
141
|
+
/** The first character `piece` puts on the line, inside the marks `outer` already opened. */
|
|
142
|
+
const pieceStart = (piece, outer, order) => {
|
|
143
|
+
const first = piece.text.match(INLINE_UNIT)?.[0];
|
|
144
|
+
if (first === void 0 || isBlank(first)) return first;
|
|
145
|
+
const opens = order.find((mark) => piece.marks.has(mark) && !outer.has(mark));
|
|
146
|
+
if (opens === void 0) return first;
|
|
147
|
+
return opens === "strike" ? "~" : "*";
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Wrap consecutive pieces in their emphasis, one mark at a time: the pieces
|
|
151
|
+
* sharing the outermost mark are wrapped once, around the rest of their
|
|
152
|
+
* emphasis. Written run by run, the closing delimiter of one would meet the
|
|
153
|
+
* opening one of the next (`*a**b*`), which no reader takes for two
|
|
154
|
+
* emphases.
|
|
155
|
+
*/
|
|
156
|
+
function renderPieces(pieces, outer, edges, order = GROUPING_ORDER) {
|
|
157
|
+
let out = "";
|
|
158
|
+
let index = 0;
|
|
159
|
+
while (index < pieces.length) {
|
|
160
|
+
const piece = pieces[index];
|
|
161
|
+
if (!piece) break;
|
|
162
|
+
const mark = order.find((key) => piece.marks.has(key) && !outer.has(key));
|
|
163
|
+
if (mark === void 0) {
|
|
164
|
+
out += piece.text;
|
|
165
|
+
index++;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
let last = index;
|
|
169
|
+
while (pieces[last + 1]?.marks.has(mark)) last++;
|
|
170
|
+
const next = pieces[last + 1];
|
|
171
|
+
const around = {
|
|
172
|
+
before: out.length > 0 ? out.at(-1) : edges.before,
|
|
173
|
+
after: next === void 0 ? edges.after : pieceStart(next, outer, order)
|
|
174
|
+
};
|
|
175
|
+
const inner = renderPieces(pieces.slice(index, last + 1), /* @__PURE__ */ new Set([...outer, mark]), around, order);
|
|
176
|
+
out += wrapFlanking(inner, mark, around);
|
|
177
|
+
index = last + 1;
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
/** The first character an item that is not a run puts on the line, where it is fixed. */
|
|
182
|
+
function renderedStart(item) {
|
|
183
|
+
if (item?.type !== "hyperlink") return void 0;
|
|
184
|
+
const link = item;
|
|
185
|
+
return link.href || link.anchor ? "[" : void 0;
|
|
186
|
+
}
|
|
59
187
|
/** Render a single run's RunContent array into the inline text fragment. */
|
|
60
188
|
function renderRunContent(ctx, pkg, content, paraId) {
|
|
61
189
|
let out = "";
|
|
@@ -81,17 +209,10 @@ function renderRunContent(ctx, pkg, content, paraId) {
|
|
|
81
209
|
out += escapeInline(item.text);
|
|
82
210
|
break;
|
|
83
211
|
case "footnoteRef":
|
|
84
|
-
case "endnoteRef":
|
|
212
|
+
case "endnoteRef":
|
|
85
213
|
if (ctx.opts.footnotes === "strip") break;
|
|
86
|
-
|
|
87
|
-
ctx.footnoteRefs.push({
|
|
88
|
-
refId: item.id,
|
|
89
|
-
markerNumber,
|
|
90
|
-
kind: item.type === "endnoteRef" ? "endnote" : "footnote"
|
|
91
|
-
});
|
|
92
|
-
out += `[^${markerNumber}]`;
|
|
214
|
+
out += numberNoteReference(ctx, item.type === "endnoteRef" ? "endnote" : "footnote", item.id).marker;
|
|
93
215
|
break;
|
|
94
|
-
}
|
|
95
216
|
case "drawing": {
|
|
96
217
|
const ref = resolveRelationshipIdOfType(pkg?.relationships, item.image.rId, RELATIONSHIP_TYPES.image);
|
|
97
218
|
const media = ref.status === "resolved" ? pkg?.media?.get(ref.relationship.target) : void 0;
|
|
@@ -118,21 +239,111 @@ function renderRunContent(ctx, pkg, content, paraId) {
|
|
|
118
239
|
}
|
|
119
240
|
return out;
|
|
120
241
|
}
|
|
121
|
-
/**
|
|
122
|
-
function
|
|
123
|
-
if (run.formatting?.hidden) return
|
|
242
|
+
/** A run's rendered text and the emphasis it still takes; `null` when it writes nothing. */
|
|
243
|
+
function pieceOf(ctx, pkg, run, paraId) {
|
|
244
|
+
if (run.formatting?.hidden) return null;
|
|
124
245
|
const inner = renderRunContent(ctx, pkg, run.content, paraId);
|
|
125
|
-
if (!inner) return
|
|
246
|
+
if (!inner) return null;
|
|
247
|
+
const marks = marksFor(run);
|
|
248
|
+
if (!marks.includes("code")) return {
|
|
249
|
+
text: inner,
|
|
250
|
+
marks: new Set(marks)
|
|
251
|
+
};
|
|
126
252
|
const leadLen = inner.length - inner.trimStart().length;
|
|
127
253
|
const trailLen = inner.length - inner.trimEnd().length;
|
|
128
254
|
const core = inner.slice(leadLen, inner.length - trailLen);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
255
|
+
return {
|
|
256
|
+
text: core ? `${inner.slice(0, leadLen)}${applyMarks(core, marks)}${inner.slice(inner.length - trailLen)}` : inner,
|
|
257
|
+
marks: /* @__PURE__ */ new Set()
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
/** What a markdown reader reads from one line: each character with its emphasis. */
|
|
261
|
+
const readLine = (line) => compileMarkdownToContent(line).content.flatMap((block) => block.type === "paragraph" ? block.content : []).flatMap((item) => item.type === "hyperlink" ? item.children : [item]).flatMap((item) => {
|
|
262
|
+
if (item.type !== "run") return [{
|
|
263
|
+
char: "\0",
|
|
264
|
+
marks: /* @__PURE__ */ new Set()
|
|
265
|
+
}];
|
|
266
|
+
const marks = new Set(GROUPING_ORDER.filter((key) => item.formatting?.[key] === true));
|
|
267
|
+
return item.content.flatMap((content) => content.type === "text" ? Array.from(content.text, (char) => ({
|
|
268
|
+
char,
|
|
269
|
+
marks
|
|
270
|
+
})) : [{
|
|
271
|
+
char: "\0",
|
|
272
|
+
marks
|
|
273
|
+
}]);
|
|
274
|
+
});
|
|
275
|
+
const sameMarks = (left, right) => left.size === right.size && [...left].every((key) => right.has(key));
|
|
276
|
+
/**
|
|
277
|
+
* How `rendered`, between `edges`, reads back: `"exact"` with the pieces'
|
|
278
|
+
* text and each letter's emphasis, `"text"` with their text alone (emphasis
|
|
279
|
+
* lost somewhere, none of it read as literal asterisks), or `null`.
|
|
280
|
+
*/
|
|
281
|
+
const readBack = (rendered, pieces, edges) => {
|
|
282
|
+
const side = (ch) => {
|
|
283
|
+
if (ch === void 0) return "x";
|
|
284
|
+
return ch === "" ? " " : ch;
|
|
285
|
+
};
|
|
286
|
+
const line = (inner) => `x ${side(edges.before)}${inner}${side(edges.after)} x`;
|
|
287
|
+
const read = readLine(line(rendered));
|
|
288
|
+
const plain = readLine(line(pieces.map(({ text }) => text).join("")));
|
|
289
|
+
if (read.map(({ char }) => char).join("") !== plain.map(({ char }) => char).join("")) return null;
|
|
290
|
+
const expected = pieces.flatMap(({ text, marks }) => readLine(`x${text}x`).slice(1, -1).map(({ char }) => ({
|
|
291
|
+
char,
|
|
292
|
+
marks
|
|
293
|
+
})));
|
|
294
|
+
const start = Array.from(`x ${side(edges.before)}`).length;
|
|
295
|
+
const end = Array.from(`${side(edges.after)} x`).length;
|
|
296
|
+
if (read.length !== start + expected.length + end) return read.every(({ marks }) => marks.size === 0) ? "text" : null;
|
|
297
|
+
let exact = true;
|
|
298
|
+
for (const [index, { char, marks }] of expected.entries()) {
|
|
299
|
+
const at = read[start + index];
|
|
300
|
+
if (at?.char !== char) return null;
|
|
301
|
+
if ([...at.marks].some((mark) => !marks.has(mark))) return null;
|
|
302
|
+
if (/[\p{L}\p{N}]/u.test(char) && !sameMarks(at.marks, marks)) exact = false;
|
|
303
|
+
}
|
|
304
|
+
return exact ? "exact" : "text";
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* Render consecutive runs with their formatting applied. The delimiters are
|
|
308
|
+
* placed by the flanking rules the reader applies, and the result is checked
|
|
309
|
+
* against the reader: a stacking it misreads is tried the other way round,
|
|
310
|
+
* or with more punctuation left outside, and failing all of those, the runs
|
|
311
|
+
* go out without emphasis rather than with stray asterisks.
|
|
312
|
+
*/
|
|
313
|
+
function renderRuns(ctx, pkg, runs, paraId, edges = UNKNOWN_NEIGHBORS) {
|
|
314
|
+
const pieces = runs.flatMap((run) => pieceOf(ctx, pkg, run, paraId) ?? []);
|
|
315
|
+
const plain = pieces.map(({ text }) => text).join("");
|
|
316
|
+
if (!pieces.some(({ marks }) => marks.size > 0)) return plain;
|
|
317
|
+
let fallback;
|
|
318
|
+
for (const split of [pieces, splitAtBlanks(pieces)]) for (const order of GROUPING_ORDERS) for (const neighbors of [edges, UNKNOWN_NEIGHBORS]) {
|
|
319
|
+
const rendered = renderPieces(split, /* @__PURE__ */ new Set(), neighbors, order);
|
|
320
|
+
const read = readBack(rendered, pieces, edges);
|
|
321
|
+
if (read === "exact") return rendered;
|
|
322
|
+
if (read === "text") fallback ??= rendered;
|
|
323
|
+
}
|
|
324
|
+
return fallback ?? plain;
|
|
133
325
|
}
|
|
326
|
+
/** The pieces with every blank a piece of its own, without emphasis. */
|
|
327
|
+
const splitAtBlanks = (pieces) => pieces.flatMap((piece) => {
|
|
328
|
+
if (piece.marks.size === 0) return [piece];
|
|
329
|
+
const parts = [];
|
|
330
|
+
for (const [unit] of piece.text.matchAll(INLINE_UNIT)) {
|
|
331
|
+
const marks = isBlank(unit) ? /* @__PURE__ */ new Set() : piece.marks;
|
|
332
|
+
const last = parts.at(-1);
|
|
333
|
+
if (last && last.marks === marks) last.text += unit;
|
|
334
|
+
else parts.push({
|
|
335
|
+
text: unit,
|
|
336
|
+
marks
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
return parts;
|
|
340
|
+
});
|
|
134
341
|
function renderHyperlink(ctx, pkg, link, paraId) {
|
|
135
|
-
const
|
|
342
|
+
const bracketed = Boolean(link.href ?? link.anchor);
|
|
343
|
+
const inner = renderRuns(ctx, pkg, getHyperlinkRuns(link), paraId, bracketed ? {
|
|
344
|
+
before: "[",
|
|
345
|
+
after: "]"
|
|
346
|
+
} : UNKNOWN_NEIGHBORS);
|
|
136
347
|
if (!inner) return "";
|
|
137
348
|
const href = link.href ?? (link.anchor ? `#${link.anchor}` : "");
|
|
138
349
|
if (!href) {
|
|
@@ -152,17 +363,17 @@ function renderHyperlink(ctx, pkg, link, paraId) {
|
|
|
152
363
|
function renderTrackedWrapper(ctx, pkg, wrapper, paraId) {
|
|
153
364
|
const renderChild = (child) => {
|
|
154
365
|
switch (child.type) {
|
|
155
|
-
case "run": return
|
|
366
|
+
case "run": return renderRuns(ctx, pkg, [child], paraId);
|
|
156
367
|
case "hyperlink": return renderHyperlink(ctx, pkg, child, paraId);
|
|
157
368
|
case "mathEquation": return child.plainText ? escapeInline(child.plainText) : "";
|
|
158
369
|
case "inlineWrapper":
|
|
159
|
-
case "inlineSdt": return renderParagraphInline(ctx, pkg, child.content, paraId);
|
|
370
|
+
case "inlineSdt": return renderParagraphInline(ctx, pkg, child.content, paraId, UNKNOWN_NEIGHBORS);
|
|
160
371
|
case "insertion":
|
|
161
372
|
case "deletion":
|
|
162
373
|
case "moveFrom":
|
|
163
374
|
case "moveTo": return renderTrackedWrapper(ctx, pkg, child, paraId);
|
|
164
375
|
case "simpleField":
|
|
165
|
-
case "complexField": return renderParagraphInline(ctx, pkg, [child], paraId);
|
|
376
|
+
case "complexField": return renderParagraphInline(ctx, pkg, [child], paraId, UNKNOWN_NEIGHBORS);
|
|
166
377
|
case "bookmarkStart":
|
|
167
378
|
case "bookmarkEnd":
|
|
168
379
|
case "moveFromRangeStart":
|
|
@@ -173,11 +384,33 @@ function renderTrackedWrapper(ctx, pkg, wrapper, paraId) {
|
|
|
173
384
|
default: return child;
|
|
174
385
|
}
|
|
175
386
|
};
|
|
387
|
+
const renderChildren = () => {
|
|
388
|
+
let rendered = "";
|
|
389
|
+
let runs = [];
|
|
390
|
+
const flush = (after) => {
|
|
391
|
+
if (runs.length === 0) return;
|
|
392
|
+
rendered += renderRuns(ctx, pkg, runs, paraId, {
|
|
393
|
+
before: rendered.length > 0 ? rendered.at(-1) : void 0,
|
|
394
|
+
after
|
|
395
|
+
});
|
|
396
|
+
runs = [];
|
|
397
|
+
};
|
|
398
|
+
for (const child of wrapper.content) {
|
|
399
|
+
if (child.type === "run") {
|
|
400
|
+
runs.push(child);
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
flush(renderedStart(child));
|
|
404
|
+
rendered += renderChild(child);
|
|
405
|
+
}
|
|
406
|
+
flush(void 0);
|
|
407
|
+
return rendered;
|
|
408
|
+
};
|
|
176
409
|
if (ctx.opts.trackedChanges === "clean") {
|
|
177
|
-
if (wrapper.type === "insertion" || wrapper.type === "moveTo") return
|
|
410
|
+
if (wrapper.type === "insertion" || wrapper.type === "moveTo") return renderChildren();
|
|
178
411
|
return "";
|
|
179
412
|
}
|
|
180
|
-
const inner =
|
|
413
|
+
const inner = renderChildren();
|
|
181
414
|
switch (wrapper.type) {
|
|
182
415
|
case "insertion": return wrapInsertion(ctx, wrapper.info, inner);
|
|
183
416
|
case "deletion": return wrapDeletion(ctx, wrapper.info, inner);
|
|
@@ -189,55 +422,76 @@ function renderTrackedWrapper(ctx, pkg, wrapper, paraId) {
|
|
|
189
422
|
* Render the full inline content of a paragraph, tracking comment-range
|
|
190
423
|
* boundaries to apply the configured wrapper.
|
|
191
424
|
*/
|
|
192
|
-
function renderParagraphInline(ctx, pkg, content, paraId
|
|
425
|
+
function renderParagraphInline(ctx, pkg, content, paraId, edges = {
|
|
426
|
+
before: "",
|
|
427
|
+
after: ""
|
|
428
|
+
}) {
|
|
193
429
|
let out = "";
|
|
194
430
|
const openComments = [];
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
out = handleCommentEnd(ctx, item, openComments, out);
|
|
213
|
-
break;
|
|
214
|
-
case "commentReference":
|
|
215
|
-
out += renderPointComment(ctx, pkg, item.id);
|
|
216
|
-
break;
|
|
217
|
-
case "simpleField":
|
|
218
|
-
case "complexField": {
|
|
219
|
-
const runs = item.type === "simpleField" ? item.content : item.fieldResult;
|
|
220
|
-
for (const child of runs) {
|
|
221
|
-
if (child.type === "run") {
|
|
222
|
-
out += renderRun(ctx, pkg, child, paraId);
|
|
223
|
-
continue;
|
|
431
|
+
const items = content.filter((item) => !SILENT_MARKERS.has(item.type) && !(ctx.opts.comments === "strip" && COMMENT_MARKERS.has(item.type)));
|
|
432
|
+
const around = (index) => {
|
|
433
|
+
const next = items[index + 1];
|
|
434
|
+
return {
|
|
435
|
+
before: out.length > 0 ? out.at(-1) : edges.before,
|
|
436
|
+
after: next === void 0 ? edges.after : renderedStart(next)
|
|
437
|
+
};
|
|
438
|
+
};
|
|
439
|
+
for (let index = 0; index < items.length; index++) {
|
|
440
|
+
const item = items[index];
|
|
441
|
+
if (item === void 0) break;
|
|
442
|
+
switch (item.type) {
|
|
443
|
+
case "run": {
|
|
444
|
+
const runs = [item];
|
|
445
|
+
while (items[index + 1]?.type === "run") {
|
|
446
|
+
runs.push(items[index + 1]);
|
|
447
|
+
index++;
|
|
224
448
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
449
|
+
out += renderRuns(ctx, pkg, runs, paraId, around(index));
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
452
|
+
case "hyperlink":
|
|
453
|
+
out += renderHyperlink(ctx, pkg, item, paraId);
|
|
454
|
+
break;
|
|
455
|
+
case "insertion":
|
|
456
|
+
case "deletion":
|
|
457
|
+
case "moveFrom":
|
|
458
|
+
case "moveTo":
|
|
459
|
+
out += renderTrackedWrapper(ctx, pkg, item, paraId);
|
|
460
|
+
break;
|
|
461
|
+
case "commentRangeStart":
|
|
462
|
+
out += handleCommentStart(ctx, pkg, item, openComments, out.length);
|
|
463
|
+
break;
|
|
464
|
+
case "commentRangeEnd":
|
|
465
|
+
out = handleCommentEnd(ctx, item, openComments, out);
|
|
466
|
+
break;
|
|
467
|
+
case "commentReference":
|
|
468
|
+
out += renderPointComment(ctx, pkg, item.id);
|
|
469
|
+
break;
|
|
470
|
+
case "simpleField":
|
|
471
|
+
case "complexField": {
|
|
472
|
+
const runs = item.type === "simpleField" ? item.content : item.fieldResult;
|
|
473
|
+
for (const child of runs) {
|
|
474
|
+
if (child.type === "run") {
|
|
475
|
+
out += renderRuns(ctx, pkg, [child], paraId);
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
if (child.type === "hyperlink") {
|
|
479
|
+
out += renderHyperlink(ctx, pkg, child, paraId);
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
out += child.type === "inlineWrapper" ? renderParagraphInline(ctx, pkg, child.content, paraId, UNKNOWN_NEIGHBORS) : child.text;
|
|
228
483
|
}
|
|
229
|
-
|
|
484
|
+
break;
|
|
230
485
|
}
|
|
231
|
-
|
|
486
|
+
case "inlineSdt":
|
|
487
|
+
case "inlineWrapper":
|
|
488
|
+
out += renderParagraphInline(ctx, pkg, item.content, paraId, around(index));
|
|
489
|
+
break;
|
|
490
|
+
case "mathEquation":
|
|
491
|
+
if (item.plainText) out += escapeInline(item.plainText);
|
|
492
|
+
break;
|
|
493
|
+
default: break;
|
|
232
494
|
}
|
|
233
|
-
case "inlineSdt":
|
|
234
|
-
case "inlineWrapper":
|
|
235
|
-
out += renderParagraphInline(ctx, pkg, item.content, paraId);
|
|
236
|
-
break;
|
|
237
|
-
case "mathEquation":
|
|
238
|
-
if (item.plainText) out += escapeInline(item.plainText);
|
|
239
|
-
break;
|
|
240
|
-
default: break;
|
|
241
495
|
}
|
|
242
496
|
while (openComments.length) {
|
|
243
497
|
const slot = openComments.pop();
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
+
import { ALT_CHUNK_READER_DIAGNOSTIC, isAltChunkMarkup } from "../docx/altChunk.js";
|
|
1
2
|
import { getHyperlinkRuns } from "../docx/hyperlinkParser.js";
|
|
3
|
+
import { OPAQUE_REVISION_CARRIER_READER_DIAGNOSTIC, isOpaqueNestedRowMarkup, opaqueRevisionCarrierName } from "../docx/opaqueCarrier.js";
|
|
2
4
|
import { RELATIONSHIP_TYPES, resolveRelationshipIdOfType } from "../docx/relsParser.js";
|
|
3
5
|
import { decodeOoxmlSymbolCharacter } from "../utils/ooxmlSymbol.js";
|
|
4
6
|
import { escapeTableCell } from "./escape.js";
|
|
5
7
|
import { registerImage } from "./images.js";
|
|
6
|
-
import { pushWarning } from "./internals.js";
|
|
8
|
+
import { numberNoteReference, pushWarning } from "./internals.js";
|
|
7
9
|
import { renderParagraph } from "./renderParagraph.js";
|
|
8
10
|
//#region src/markdown/renderTable.ts
|
|
9
11
|
/** Render a `Table` as markdown. Picks GFM vs HTML based on cell features. */
|
|
10
12
|
function renderTable(ctx, pkg, table) {
|
|
11
13
|
const { rows } = table;
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
return renderGfmTable(ctx, pkg, rows, true);
|
|
14
|
+
const diagnostics = [...preservedCarrierDiagnostics(table.preserved?.children), ...rows.flatMap((row) => preservedCarrierDiagnostics(row.preserved?.children))];
|
|
15
|
+
if (!rows.length) return diagnostics.join("\n");
|
|
16
|
+
return [needsHtmlFallback(rows) ? renderHtmlTable(ctx, pkg, rows, true) : renderGfmTable(ctx, pkg, rows, true), ...diagnostics].filter(Boolean).join("\n\n");
|
|
15
17
|
}
|
|
18
|
+
const preservedCarrierDiagnostics = (children) => (children ?? []).flatMap(({ xml }) => {
|
|
19
|
+
if (isAltChunkMarkup(xml)) return [ALT_CHUNK_READER_DIAGNOSTIC];
|
|
20
|
+
if (opaqueRevisionCarrierName(xml) !== void 0) return [OPAQUE_REVISION_CARRIER_READER_DIAGNOSTIC];
|
|
21
|
+
return isOpaqueNestedRowMarkup(xml) ? ["[Unsupported nested w:tr content]"] : [];
|
|
22
|
+
});
|
|
16
23
|
function needsHtmlFallback(rows) {
|
|
17
24
|
for (const row of rows) for (const cell of row.cells) {
|
|
18
25
|
if ((cell.formatting?.gridSpan ?? 1) > 1) return true;
|
|
@@ -64,10 +71,15 @@ function renderGfmCell(ctx, pkg, cell) {
|
|
|
64
71
|
break;
|
|
65
72
|
}
|
|
66
73
|
case "blockSdt":
|
|
74
|
+
case "blockCustomXml":
|
|
67
75
|
renderBlocks(item.content);
|
|
68
76
|
break;
|
|
69
|
-
case "table":
|
|
77
|
+
case "table": break;
|
|
70
78
|
case "preservedBlock":
|
|
79
|
+
if (isAltChunkMarkup(item.xml)) blocks.push(item.readerText === void 0 ? ALT_CHUNK_READER_DIAGNOSTIC : `${ALT_CHUNK_READER_DIAGNOSTIC}\n${item.readerText}`);
|
|
80
|
+
else if (opaqueRevisionCarrierName(item.xml) !== void 0) blocks.push(OPAQUE_REVISION_CARRIER_READER_DIAGNOSTIC);
|
|
81
|
+
else if (isOpaqueNestedRowMarkup(item.xml)) blocks.push("[Unsupported nested w:tr content]");
|
|
82
|
+
break;
|
|
71
83
|
case "bookmarkStart":
|
|
72
84
|
case "bookmarkEnd": break;
|
|
73
85
|
default: return item;
|
|
@@ -139,9 +151,14 @@ function renderHtmlCell(ctx, pkg, cell) {
|
|
|
139
151
|
break;
|
|
140
152
|
}
|
|
141
153
|
case "blockSdt":
|
|
154
|
+
case "blockCustomXml":
|
|
142
155
|
renderBlocks(item.content);
|
|
143
156
|
break;
|
|
144
157
|
case "preservedBlock":
|
|
158
|
+
if (isAltChunkMarkup(item.xml)) parts.push(item.readerText === void 0 ? ALT_CHUNK_READER_DIAGNOSTIC : `${ALT_CHUNK_READER_DIAGNOSTIC} ${item.readerText}`);
|
|
159
|
+
else if (opaqueRevisionCarrierName(item.xml) !== void 0) parts.push(OPAQUE_REVISION_CARRIER_READER_DIAGNOSTIC);
|
|
160
|
+
else if (isOpaqueNestedRowMarkup(item.xml)) parts.push("[Unsupported nested w:tr content]");
|
|
161
|
+
break;
|
|
145
162
|
case "bookmarkStart":
|
|
146
163
|
case "bookmarkEnd": break;
|
|
147
164
|
default: return item;
|
|
@@ -257,13 +274,8 @@ function renderHtmlRun(ctx, pkg, run, paraId) {
|
|
|
257
274
|
case "footnoteRef":
|
|
258
275
|
case "endnoteRef": {
|
|
259
276
|
if (ctx.opts.footnotes === "strip") break;
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
refId: item.id,
|
|
263
|
-
markerNumber,
|
|
264
|
-
kind: item.type === "endnoteRef" ? "endnote" : "footnote"
|
|
265
|
-
});
|
|
266
|
-
text += `<sup>[${markerNumber}]</sup>`;
|
|
277
|
+
const { token } = numberNoteReference(ctx, item.type === "endnoteRef" ? "endnote" : "footnote", item.id);
|
|
278
|
+
text += `<sup>[${token}]</sup>`;
|
|
267
279
|
break;
|
|
268
280
|
}
|
|
269
281
|
default: break;
|
|
@@ -18,9 +18,9 @@ import { panic } from "better-result";
|
|
|
18
18
|
function appendTrailers(ctx, doc, body) {
|
|
19
19
|
const sections = body.trim() ? [body] : [];
|
|
20
20
|
if (ctx.footnoteRefs.length > 0) {
|
|
21
|
-
const refs = ctx.footnoteRefs.map(({ refId,
|
|
21
|
+
const refs = ctx.footnoteRefs.map(({ refId, marker, kind }) => {
|
|
22
22
|
const note = kind === "endnote" ? doc.package.endnotes?.find((n) => n.id === refId) : doc.package.footnotes?.find((f) => f.id === refId);
|
|
23
|
-
return
|
|
23
|
+
return `${marker}: ${note ? noteText(ctx, doc, note) : ""}`;
|
|
24
24
|
});
|
|
25
25
|
sections.push(refs.join("\n"));
|
|
26
26
|
}
|
package/dist/markdown/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { NoteReferenceKind, NoteReferenceNumbering } from "../utils/noteReferenceLabels.js";
|
|
1
2
|
import { BuiltInStyleIndex } from "../docx/builtInStyles.js";
|
|
3
|
+
import { ListLabelCounter } from "../prosemirror/listLabels.js";
|
|
2
4
|
//#region src/markdown/types.d.ts
|
|
3
5
|
/**
|
|
4
6
|
* Metadata describing a single image registration. Owned by the markdown
|
|
@@ -106,12 +108,18 @@ type RenderContext = {
|
|
|
106
108
|
imagesByPath: Map<string, ImageRef>;
|
|
107
109
|
/** Diagnostics accumulator. */
|
|
108
110
|
warnings: string[];
|
|
109
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* Footnote/endnote refs collected during this render, one per note in the
|
|
113
|
+
* order it is first referenced. `marker` is what the body line shows
|
|
114
|
+
* (`[^1]`, `[^e1]`) and what the definition trailer repeats.
|
|
115
|
+
*/
|
|
110
116
|
footnoteRefs: {
|
|
111
117
|
refId: number;
|
|
112
|
-
|
|
113
|
-
kind:
|
|
118
|
+
marker: string;
|
|
119
|
+
kind: NoteReferenceKind;
|
|
114
120
|
}[];
|
|
121
|
+
/** Reading-order note numbering, shared with the AI text view. */
|
|
122
|
+
noteNumbering: NoteReferenceNumbering;
|
|
115
123
|
/** Comment refs collected during this render (sidecar mode only). */
|
|
116
124
|
commentRefs: {
|
|
117
125
|
commentId: number;
|
|
@@ -124,12 +132,26 @@ type RenderContext = {
|
|
|
124
132
|
}[];
|
|
125
133
|
/** 1-based counter for default virtual paths. */
|
|
126
134
|
imageCounter: number;
|
|
127
|
-
/**
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Advances past one paragraph, in document order, and answers the list
|
|
137
|
+
* label it shows: the page's own counter, so the numbers follow the
|
|
138
|
+
* document as it stands rather than the markers resolved when it was read.
|
|
139
|
+
*/
|
|
140
|
+
nextListLabel: ListLabelCounter;
|
|
131
141
|
/** The document's styles indexed by the built-in they are; classifies headings and quotes. */
|
|
132
142
|
builtInStyles: BuiltInStyleIndex;
|
|
143
|
+
/**
|
|
144
|
+
* The rendered width (marker text + one trailing space) of the most
|
|
145
|
+
* recently emitted list item at each level, indexed by `ListRendering.level`.
|
|
146
|
+
* A nested item's indent is the sum of every shallower level's width here,
|
|
147
|
+
* not a fixed two spaces: CommonMark only keeps a child nested under its
|
|
148
|
+
* parent when the child starts at or past the column where the parent's
|
|
149
|
+
* content begins, and a marker like `10. ` or `1. ` is wider than `- `.
|
|
150
|
+
* Document order visits a parent before its children, so by the time a
|
|
151
|
+
* level-N item renders, levels `0..N-1` already hold the current ancestor
|
|
152
|
+
* chain's widths.
|
|
153
|
+
*/
|
|
154
|
+
listIndentWidths: number[];
|
|
133
155
|
};
|
|
134
156
|
//#endregion
|
|
135
157
|
export { ImageMeta, ImageRef, MarkdownOptions, MarkdownResult, RenderContext, ResolvedOptions };
|
|
@@ -17,8 +17,7 @@ type IncrementalMeasureResult = {
|
|
|
17
17
|
measures: Measure[];
|
|
18
18
|
measuredBlockIndexes: number[];
|
|
19
19
|
};
|
|
20
|
-
declare function mergeDirtyRanges(first: DirtyRange | null, second: DirtyRange | null): DirtyRange | null;
|
|
21
20
|
declare function findDirtyBlockIndexes(blocks: FlowBlock[], dirtyRange: DirtyRange): number[];
|
|
22
21
|
declare function tryBuildIncrementalMeasures({ previousBlocks, previousMeasures, previousBlockWidths, nextBlocks, nextBlockWidths, dirtyRange, measureBlock }: IncrementalMeasureInput): IncrementalMeasureResult | null;
|
|
23
22
|
//#endregion
|
|
24
|
-
export { DirtyRange, IncrementalMeasureInput, IncrementalMeasureResult, findDirtyBlockIndexes,
|
|
23
|
+
export { DirtyRange, IncrementalMeasureInput, IncrementalMeasureResult, findDirtyBlockIndexes, tryBuildIncrementalMeasures };
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
//#region src/paged-layout/incrementalMeasure.ts
|
|
2
|
-
function mergeDirtyRanges(first, second) {
|
|
3
|
-
if (!first) return second;
|
|
4
|
-
if (!second) return first;
|
|
5
|
-
return {
|
|
6
|
-
from: Math.min(first.from, second.from),
|
|
7
|
-
to: Math.max(first.to, second.to)
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
2
|
function findDirtyBlockIndexes(blocks, dirtyRange) {
|
|
11
3
|
const indexes = [];
|
|
12
4
|
const dirtyFrom = Math.min(dirtyRange.from, dirtyRange.to);
|
|
@@ -53,4 +45,4 @@ function isIncrementalMeasureEligibleBlock(block) {
|
|
|
53
45
|
});
|
|
54
46
|
}
|
|
55
47
|
//#endregion
|
|
56
|
-
export { findDirtyBlockIndexes,
|
|
48
|
+
export { findDirtyBlockIndexes, tryBuildIncrementalMeasures };
|
|
@@ -2,7 +2,5 @@ import { DirtyRange } from "./incrementalMeasure.js";
|
|
|
2
2
|
import { Transaction } from "prosemirror-state";
|
|
3
3
|
//#region src/paged-layout/transactionDirtyRange.d.ts
|
|
4
4
|
declare function getTransactionDirtyRange(transaction: Transaction): DirtyRange | null;
|
|
5
|
-
/** Collect every transaction in an applied batch in the final document's coordinates. */
|
|
6
|
-
declare function getTransactionsDirtyRange(transactions: readonly Transaction[]): DirtyRange | null;
|
|
7
5
|
//#endregion
|
|
8
|
-
export { getTransactionDirtyRange
|
|
6
|
+
export { getTransactionDirtyRange };
|