@ai-matrx/rich-content 0.2.4 → 0.2.6
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/CHANGELOG.md +18 -0
- package/dist/code-block/CodeBlock.d.ts +44 -0
- package/dist/code-block/CodeBlock.js +449 -0
- package/dist/code-block/CodeBlockHeader.d.ts +63 -0
- package/dist/code-block/CodeBlockHeader.js +472 -0
- package/dist/code-block/CodeEditorLoading.d.ts +3 -0
- package/dist/code-block/CodeEditorLoading.js +34 -0
- package/dist/code-block/LanguageDisplay.d.ts +28 -0
- package/dist/code-block/LanguageDisplay.js +279 -0
- package/dist/code-block/SmallCodeEditor.d.ts +30 -0
- package/dist/code-block/SmallCodeEditor.js +22 -0
- package/dist/code-block/StickyButtons.d.ts +35 -0
- package/dist/code-block/StickyButtons.js +88 -0
- package/dist/code-block/highlight/ShikiCodeView.d.ts +26 -0
- package/dist/code-block/highlight/ShikiCodeView.js +134 -0
- package/dist/code-block/highlight/shiki-highlighter.d.ts +14 -0
- package/dist/code-block/highlight/shiki-highlighter.js +126 -0
- package/dist/code-block/highlight/useHighlightedLines.d.ts +18 -0
- package/dist/code-block/highlight/useHighlightedLines.js +142 -0
- package/dist/code-block/sticky-inset.d.ts +6 -0
- package/dist/code-block/sticky-inset.js +10 -0
- package/dist/display/block-interaction.d.ts +33 -0
- package/dist/display/block-interaction.js +13 -0
- package/dist/display/blocks/ChatCollapsibleWrapper.d.ts +13 -0
- package/dist/display/blocks/ChatCollapsibleWrapper.js +56 -0
- package/dist/display/blocks/buildMediaSource.d.ts +25 -0
- package/dist/display/blocks/buildMediaSource.js +43 -0
- package/dist/display/blocks/canvas-adaptive.d.ts +118 -0
- package/dist/display/blocks/canvas-adaptive.js +127 -0
- package/dist/display/blocks/canvas-fit.d.ts +24 -0
- package/dist/display/blocks/canvas-fit.js +19 -0
- package/dist/display/blocks/chart/ChartBlock.d.ts +8 -0
- package/dist/display/blocks/chart/ChartBlock.js +125 -0
- package/dist/display/blocks/chart/ChartCanvas.d.ts +18 -0
- package/dist/display/blocks/chart/ChartCanvas.js +159 -0
- package/dist/display/blocks/chart/TableChart.d.ts +25 -0
- package/dist/display/blocks/chart/TableChart.js +97 -0
- package/dist/display/blocks/chart/chart-spec.d.ts +39 -0
- package/dist/display/blocks/chart/chart-spec.js +128 -0
- package/dist/display/blocks/chart/labels.d.ts +20 -0
- package/dist/display/blocks/chart/labels.js +7 -0
- package/dist/display/blocks/chart/table-chart.d.ts +37 -0
- package/dist/display/blocks/chart/table-chart.js +231 -0
- package/dist/display/blocks/common/BlockHeaderWrapper.d.ts +56 -0
- package/dist/display/blocks/common/BlockHeaderWrapper.js +310 -0
- package/dist/display/blocks/common/ContentBlockWrapper.d.ts +40 -0
- package/dist/display/blocks/common/ContentBlockWrapper.js +214 -0
- package/dist/display/blocks/common/SandboxedHtml.d.ts +27 -0
- package/dist/display/blocks/common/SandboxedHtml.js +26 -0
- package/dist/display/blocks/diagram/DiagramLoadingVisualization.d.ts +6 -0
- package/dist/display/blocks/diagram/DiagramLoadingVisualization.js +190 -0
- package/dist/display/blocks/diagram/InteractiveDiagramBlock.d.ts +51 -0
- package/dist/display/blocks/diagram/InteractiveDiagramBlock.js +2415 -0
- package/dist/display/blocks/diagram/diagram-printer.d.ts +16 -0
- package/dist/display/blocks/diagram/diagram-printer.js +294 -0
- package/dist/display/blocks/diagram/diagram-visual-defaults.d.ts +116 -0
- package/dist/display/blocks/diagram/diagram-visual-defaults.js +400 -0
- package/dist/display/blocks/diagram/layout-utils.d.ts +90 -0
- package/dist/display/blocks/diagram/layout-utils.js +347 -0
- package/dist/display/blocks/diagram/parseDiagramJSON.d.ts +105 -0
- package/dist/display/blocks/diagram/parseDiagramJSON.js +296 -0
- package/dist/display/blocks/diagram/presentation-direction.d.ts +29 -0
- package/dist/display/blocks/diagram/presentation-direction.js +19 -0
- package/dist/display/blocks/diagram/ui-utils.d.ts +1 -0
- package/dist/display/blocks/diagram/ui-utils.js +18 -0
- package/dist/display/blocks/diff/DiffBlock.d.ts +10 -0
- package/dist/display/blocks/diff/DiffBlock.js +119 -0
- package/dist/display/blocks/diff/DiffCanvas.d.ts +15 -0
- package/dist/display/blocks/diff/DiffCanvas.js +20 -0
- package/dist/display/blocks/generic/GenericStructuredBlock.d.ts +24 -0
- package/dist/display/blocks/generic/GenericStructuredBlock.js +53 -0
- package/dist/display/blocks/generic/StructuredValueTabs.d.ts +21 -0
- package/dist/display/blocks/generic/StructuredValueTabs.js +124 -0
- package/dist/display/blocks/generic/tile-actions-slot.d.ts +39 -0
- package/dist/display/blocks/generic/tile-actions-slot.js +33 -0
- package/dist/display/blocks/images/ImageBlock.d.ts +8 -0
- package/dist/display/blocks/images/ImageBlock.js +265 -0
- package/dist/display/blocks/json/JsonBlock.d.ts +34 -0
- package/dist/display/blocks/json/JsonBlock.js +562 -0
- package/dist/display/blocks/json/JsonTableView.d.ts +10 -0
- package/dist/display/blocks/json/JsonTableView.js +173 -0
- package/dist/display/blocks/json/json-compact-stringify.d.ts +25 -0
- package/dist/display/blocks/json/json-compact-stringify.js +52 -0
- package/dist/display/blocks/json/json-tabular-utils.d.ts +65 -0
- package/dist/display/blocks/json/json-tabular-utils.js +121 -0
- package/dist/display/blocks/links/LinkComponent.d.ts +6 -0
- package/dist/display/blocks/links/LinkComponent.js +373 -0
- package/dist/display/blocks/links/LinkComponentWithFetch.d.ts +1 -0
- package/dist/display/blocks/links/LinkComponentWithFetch.js +0 -0
- package/dist/display/blocks/markdown/MarkdownKindBlock.d.ts +48 -0
- package/dist/display/blocks/markdown/MarkdownKindBlock.js +52 -0
- package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.d.ts +17 -0
- package/dist/display/blocks/markdown-preview/MarkdownPreviewBlock.js +70 -0
- package/dist/display/blocks/mermaid/MermaidBlock.d.ts +19 -0
- package/dist/display/blocks/mermaid/MermaidBlock.js +386 -0
- package/dist/display/blocks/search-replace/SearchReplaceBlock.d.ts +50 -0
- package/dist/display/blocks/search-replace/SearchReplaceBlock.js +71 -0
- package/dist/display/blocks/svg/SvgBlock.d.ts +8 -0
- package/dist/display/blocks/svg/SvgBlock.js +126 -0
- package/dist/display/blocks/table/StreamingTableRenderer.d.ts +53 -0
- package/dist/display/blocks/table/StreamingTableRenderer.js +907 -0
- package/dist/display/blocks/table/TableRenderPathDiagnostic.d.ts +21 -0
- package/dist/display/blocks/table/TableRenderPathDiagnostic.js +79 -0
- package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.d.ts +14 -0
- package/dist/display/blocks/thinking-reasoning/ConsolidatedReasoningVisualization.js +15 -0
- package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.d.ts +13 -0
- package/dist/display/blocks/thinking-reasoning/ReasoningVisualization.js +19 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTrace.d.ts +30 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTrace.js +75 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.d.ts +13 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingTraceMarkdown.js +48 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.d.ts +12 -0
- package/dist/display/blocks/thinking-reasoning/ThinkingVisualization.js +19 -0
- package/dist/display/blocks/toml/TomlBlock.d.ts +7 -0
- package/dist/display/blocks/toml/TomlBlock.js +167 -0
- package/dist/display/blocks/tree/TreeBlock.d.ts +7 -0
- package/dist/display/blocks/tree/TreeBlock.js +163 -0
- package/dist/display/blocks/xml/XmlBlock.d.ts +23 -0
- package/dist/display/blocks/xml/XmlBlock.js +197 -0
- package/dist/display/blocks/xml/readXmlTag.d.ts +1 -0
- package/dist/display/blocks/xml/readXmlTag.js +1 -0
- package/dist/display/blocks/xml/xml-tokenize.d.ts +13 -0
- package/dist/display/blocks/xml/xml-tokenize.js +169 -0
- package/dist/display/blocks/yaml/YamlBlock.d.ts +7 -0
- package/dist/display/blocks/yaml/YamlBlock.js +191 -0
- package/dist/display/chat-markdown/BasicMarkdownContent.d.ts +29 -0
- package/dist/display/chat-markdown/BasicMarkdownContent.js +122 -0
- package/dist/display/chat-markdown/BlockRenderingContext.d.ts +23 -0
- package/dist/display/chat-markdown/BlockRenderingContext.js +17 -0
- package/dist/display/chat-markdown/ConfigurableMarkdownContent.d.ts +172 -0
- package/dist/display/chat-markdown/ConfigurableMarkdownContent.js +649 -0
- package/dist/display/chat-markdown/InlineCodeSnippet.d.ts +19 -0
- package/dist/display/chat-markdown/InlineCodeSnippet.js +146 -0
- package/dist/display/chat-markdown/InlineCodeSnippetKindGate.d.ts +11 -0
- package/dist/display/chat-markdown/InlineCodeSnippetKindGate.js +9 -0
- package/dist/display/chat-markdown/KindTextGate.d.ts +31 -0
- package/dist/display/chat-markdown/KindTextGate.js +60 -0
- package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.d.ts +6 -0
- package/dist/display/chat-markdown/QuestionnaireLoadingVisualization.js +92 -0
- package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.d.ts +72 -0
- package/dist/display/chat-markdown/block-registry/BlockComponentRegistry.js +94 -0
- package/dist/display/chat-markdown/block-registry/BlockRenderer.d.ts +126 -0
- package/dist/display/chat-markdown/block-registry/BlockRenderer.js +473 -0
- package/dist/display/chat-markdown/block-registry/block-dispatch.d.ts +410 -0
- package/dist/display/chat-markdown/block-registry/block-dispatch.js +495 -0
- package/dist/display/chat-markdown/block-registry/json-parse-utils.d.ts +13 -0
- package/dist/display/chat-markdown/block-registry/json-parse-utils.js +236 -0
- package/dist/display/chat-markdown/constants.d.ts +14 -0
- package/dist/display/chat-markdown/constants.js +317 -0
- package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.d.ts +31 -0
- package/dist/display/chat-markdown/diff-blocks/DiffCollapsible.js +62 -0
- package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.d.ts +12 -0
- package/dist/display/chat-markdown/diff-blocks/DiffLoadingIndicator.js +18 -0
- package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.d.ts +22 -0
- package/dist/display/chat-markdown/diff-blocks/StreamingDiffBlock.js +130 -0
- package/dist/display/chat-markdown/diff-blocks/diff-style-registry.d.ts +21 -0
- package/dist/display/chat-markdown/diff-blocks/diff-style-registry.js +91 -0
- package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.d.ts +26 -0
- package/dist/display/chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.js +186 -0
- package/dist/display/chat-markdown/diff-blocks/types.d.ts +56 -0
- package/dist/display/chat-markdown/diff-blocks/types.js +0 -0
- package/dist/display/chat-markdown/internal-handlers/BlockFallback.d.ts +20 -0
- package/dist/display/chat-markdown/internal-handlers/BlockFallback.js +83 -0
- package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.d.ts +4 -0
- package/dist/display/chat-markdown/internal-handlers/InlineStatusIndicator.js +16 -0
- package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.d.ts +17 -0
- package/dist/display/chat-markdown/internal-handlers/MarkdownErrorBoundary.js +40 -0
- package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.d.ts +8 -0
- package/dist/display/chat-markdown/internal-handlers/PlainTextFallback.js +91 -0
- package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.d.ts +20 -0
- package/dist/display/chat-markdown/internal-handlers/SafeBlockRenderer.js +72 -0
- package/dist/display/chat-markdown/kind-source-view.d.ts +14 -0
- package/dist/display/chat-markdown/kind-source-view.js +14 -0
- package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.d.ts +28 -0
- package/dist/display/chat-markdown/matrx-variables/MatrxVariableInline.js +65 -0
- package/dist/display/chat-markdown/progressive-mount.d.ts +18 -0
- package/dist/display/chat-markdown/progressive-mount.js +90 -0
- package/dist/display/chat-markdown/render-block-to-content-block.d.ts +31 -0
- package/dist/display/chat-markdown/render-block-to-content-block.js +32 -0
- package/dist/display/chat-markdown/settle-stream-blocks.d.ts +50 -0
- package/dist/display/chat-markdown/settle-stream-blocks.js +26 -0
- package/dist/display/chat-markdown/stable-blocks.d.ts +15 -0
- package/dist/display/chat-markdown/stable-blocks.js +54 -0
- package/dist/display/chat-markdown/types.d.ts +11 -0
- package/dist/display/chat-markdown/types.js +26 -0
- package/dist/display/specimen/SpecimenContext.d.ts +26 -0
- package/dist/display/specimen/SpecimenContext.js +64 -0
- package/dist/display/tables/MarkdownTable.d.ts +23 -0
- package/dist/display/tables/MarkdownTable.js +769 -0
- package/dist/display/tables/MarkdownTableScrollArea.d.ts +12 -0
- package/dist/display/tables/MarkdownTableScrollArea.js +92 -0
- package/dist/display/tables/SendToGoogleSheetButton.d.ts +19 -0
- package/dist/display/tables/SendToGoogleSheetButton.js +93 -0
- package/dist/display/tables/SendToWorkbookButton.d.ts +24 -0
- package/dist/display/tables/SendToWorkbookButton.js +93 -0
- package/dist/display/tables/TableSaveToMenu.d.ts +16 -0
- package/dist/display/tables/TableSaveToMenu.js +98 -0
- package/dist/display/tables/TableWithSeparatedControls.d.ts +22 -0
- package/dist/display/tables/TableWithSeparatedControls.js +574 -0
- package/dist/display/tables/ViewTableModal.d.ts +14 -0
- package/dist/display/tables/ViewTableModal.js +67 -0
- package/dist/display/tables/editing/ColumnActionsMenu.d.ts +16 -0
- package/dist/display/tables/editing/ColumnActionsMenu.js +80 -0
- package/dist/display/tables/editing/RowActionsMenu.d.ts +16 -0
- package/dist/display/tables/editing/RowActionsMenu.js +80 -0
- package/dist/display/tables/editing/TableEditToolbar.d.ts +15 -0
- package/dist/display/tables/editing/TableEditToolbar.js +63 -0
- package/dist/display/tables/editing/tableMutations.d.ts +50 -0
- package/dist/display/tables/editing/tableMutations.js +148 -0
- package/dist/display/tables/editing/useDoubleClickEdit.d.ts +43 -0
- package/dist/display/tables/editing/useDoubleClickEdit.js +51 -0
- package/dist/display/tables/editing/useTableUndo.d.ts +25 -0
- package/dist/display/tables/editing/useTableUndo.js +17 -0
- package/dist/display/tables/table-action-row.d.ts +8 -0
- package/dist/display/tables/table-action-row.js +31 -0
- package/dist/display/tables/table-viewer.d.ts +13 -0
- package/dist/display/tables/table-viewer.js +18 -0
- package/dist/host/ErrorActions.d.ts +1 -1
- package/dist/host/ErrorNotice.d.ts +10 -0
- package/dist/host/ErrorNotice.js +19 -0
- package/dist/host/app-bindings.d.ts +155 -0
- package/dist/host/app-bindings.js +160 -0
- package/dist/host/diagnostics.d.ts +2 -2
- package/dist/host/diagnostics.js +2 -1
- package/dist/host/tables.d.ts +1 -6
- package/dist/host/types.d.ts +14 -7
- package/dist/levels/RichContent.d.ts +3 -0
- package/dist/levels/RichContent.js +102 -0
- package/dist/levels/RichContentInline.d.ts +28 -0
- package/dist/levels/RichContentInline.js +61 -0
- package/dist/levels/RichContentPreview.d.ts +12 -0
- package/dist/levels/RichContentPreview.js +39 -0
- package/dist/levels/RichContentStandardImpl.d.ts +12 -0
- package/dist/levels/RichContentStandardImpl.js +27 -0
- package/dist/levels/RichContentStaticProse.d.ts +46 -0
- package/dist/levels/RichContentStaticProse.js +100 -0
- package/dist/levels/depth.d.ts +18 -0
- package/dist/levels/depth.js +32 -0
- package/dist/levels/prose/inline-level-elements.d.ts +19 -0
- package/dist/levels/prose/inline-level-elements.js +103 -0
- package/dist/levels/prose/prose-block-elements.d.ts +25 -0
- package/dist/levels/prose/prose-block-elements.js +313 -0
- package/dist/levels/prose/prose-inline-elements.d.ts +13 -0
- package/dist/levels/prose/prose-inline-elements.js +143 -0
- package/dist/levels/prose/prose-prepare.d.ts +50 -0
- package/dist/levels/prose/prose-prepare.js +246 -0
- package/dist/levels/prose/remote-image-policy.d.ts +34 -0
- package/dist/levels/prose/remote-image-policy.js +153 -0
- package/dist/levels/prose/variant-root.d.ts +9 -0
- package/dist/levels/prose/variant-root.js +34 -0
- package/dist/levels/rich-content-types.d.ts +93 -0
- package/dist/levels/rich-content-types.js +4 -0
- package/dist/levels/server/DelimiterViolationReport.d.ts +7 -0
- package/dist/levels/server/DelimiterViolationReport.js +24 -0
- package/dist/levels/server/RichContentServer.d.ts +27 -0
- package/dist/levels/server/RichContentServer.js +97 -0
- package/dist/levels/standard/NestedRichContent.d.ts +7 -0
- package/dist/levels/standard/NestedRichContent.js +70 -0
- package/dist/levels/standard/StandardBlocks.d.ts +13 -0
- package/dist/levels/standard/StandardBlocks.js +239 -0
- package/dist/levels/standard/StandardKindRegion.d.ts +14 -0
- package/dist/levels/standard/StandardKindRegion.js +69 -0
- package/dist/levels/standard/standard-kind-region.d.ts +19 -0
- package/dist/levels/standard/standard-kind-region.js +21 -0
- package/dist/levels/standard/static-standard.d.ts +23 -0
- package/dist/levels/standard/static-standard.js +187 -0
- package/dist/levels/standard/stream-holdback.d.ts +2 -0
- package/dist/levels/standard/stream-holdback.js +77 -0
- package/dist/mermaid/MermaidFullscreen.d.ts +17 -0
- package/dist/mermaid/MermaidFullscreen.js +71 -0
- package/dist/mermaid/MermaidRenderer.d.ts +20 -0
- package/dist/mermaid/MermaidRenderer.js +267 -0
- package/dist/mermaid/MermaidView.d.ts +27 -0
- package/dist/mermaid/MermaidView.js +68 -0
- package/dist/mermaid/MermaidViewport.d.ts +75 -0
- package/dist/mermaid/MermaidViewport.js +286 -0
- package/dist/mermaid/adapters/er.d.ts +10 -0
- package/dist/mermaid/adapters/er.js +205 -0
- package/dist/mermaid/adapters/flowchart.d.ts +17 -0
- package/dist/mermaid/adapters/flowchart.js +634 -0
- package/dist/mermaid/adapters/journey.d.ts +9 -0
- package/dist/mermaid/adapters/journey.js +207 -0
- package/dist/mermaid/adapters/mindmap.d.ts +12 -0
- package/dist/mermaid/adapters/mindmap.js +252 -0
- package/dist/mermaid/adapters/pie.d.ts +7 -0
- package/dist/mermaid/adapters/pie.js +172 -0
- package/dist/mermaid/adapters/quadrant.d.ts +8 -0
- package/dist/mermaid/adapters/quadrant.js +231 -0
- package/dist/mermaid/adapters/register.d.ts +7 -0
- package/dist/mermaid/adapters/register.js +19 -0
- package/dist/mermaid/adapters/sequence.d.ts +8 -0
- package/dist/mermaid/adapters/sequence.js +251 -0
- package/dist/mermaid/adapters/state.d.ts +12 -0
- package/dist/mermaid/adapters/state.js +245 -0
- package/dist/mermaid/adapters/timeline.d.ts +8 -0
- package/dist/mermaid/adapters/timeline.js +245 -0
- package/dist/mermaid/catalog.d.ts +33 -0
- package/dist/mermaid/catalog.js +202 -0
- package/dist/mermaid/diagram-type.d.ts +39 -0
- package/dist/mermaid/diagram-type.js +89 -0
- package/dist/mermaid/export.d.ts +21 -0
- package/dist/mermaid/export.js +112 -0
- package/dist/mermaid/extract-fence.d.ts +15 -0
- package/dist/mermaid/extract-fence.js +22 -0
- package/dist/mermaid/lazy-draw.d.ts +40 -0
- package/dist/mermaid/lazy-draw.js +168 -0
- package/dist/mermaid/model/adapter.d.ts +28 -0
- package/dist/mermaid/model/adapter.js +16 -0
- package/dist/mermaid/model/ops.d.ts +282 -0
- package/dist/mermaid/model/ops.js +9 -0
- package/dist/mermaid/model/round-trip.d.ts +22 -0
- package/dist/mermaid/model/round-trip.js +45 -0
- package/dist/mermaid/model/types.d.ts +271 -0
- package/dist/mermaid/model/types.js +0 -0
- package/dist/mermaid/print-render.d.ts +9 -0
- package/dist/mermaid/print-render.js +39 -0
- package/dist/mermaid/runtime.d.ts +25 -0
- package/dist/mermaid/runtime.js +183 -0
- package/dist/mermaid/sanitize.d.ts +46 -0
- package/dist/mermaid/sanitize.js +234 -0
- package/dist/mermaid/types.d.ts +43 -0
- package/dist/mermaid/types.js +21 -0
- package/dist/mermaid/view/ViewModePane.d.ts +24 -0
- package/dist/mermaid/view/ViewModePane.js +9 -0
- package/dist/utils/client-lazy.d.ts +1 -1
- package/dist/utils/client-lazy.js +4 -1
- package/dist/utils/lifted/DiffView.d.ts +10 -0
- package/dist/utils/lifted/DiffView.js +26 -0
- package/dist/utils/lifted/IconButton.d.ts +24 -0
- package/dist/utils/lifted/IconButton.js +43 -0
- package/dist/utils/lifted/MatrxMiniLoader.d.ts +1 -0
- package/dist/utils/lifted/MatrxMiniLoader.js +8 -0
- package/dist/utils/lifted/ShimmerText.d.ts +5 -0
- package/dist/utils/lifted/ShimmerText.js +21 -0
- package/dist/utils/lifted/SuspenseLoader.d.ts +16 -0
- package/dist/utils/lifted/SuspenseLoader.js +42 -0
- package/dist/utils/lifted/Tooltip.d.ts +20 -0
- package/dist/utils/lifted/Tooltip.js +52 -0
- package/dist/utils/lifted/artifactId.d.ts +34 -0
- package/dist/utils/lifted/artifactId.js +15 -0
- package/dist/utils/lifted/canvasContent.d.ts +63 -0
- package/dist/utils/lifted/canvasContent.js +98 -0
- package/dist/utils/lifted/captureReactError.d.ts +24 -0
- package/dist/utils/lifted/captureReactError.js +28 -0
- package/dist/utils/lifted/chunk-load-recovery.d.ts +25 -0
- package/dist/utils/lifted/chunk-load-recovery.js +36 -0
- package/dist/utils/lifted/code-editor-agent-types.d.ts +6 -0
- package/dist/utils/lifted/code-editor-agent-types.js +0 -0
- package/dist/utils/lifted/code-editor-agents.d.ts +39 -0
- package/dist/utils/lifted/code-editor-agents.js +52 -0
- package/dist/utils/lifted/code-language-extension.d.ts +1 -0
- package/dist/utils/lifted/code-language-extension.js +60 -0
- package/dist/utils/lifted/custom-icons.d.ts +16 -0
- package/dist/utils/lifted/custom-icons.js +47 -0
- package/dist/utils/lifted/durability.d.ts +16 -0
- package/dist/utils/lifted/durability.js +45 -0
- package/dist/utils/lifted/errors.d.ts +30 -0
- package/dist/utils/lifted/errors.js +29 -0
- package/dist/utils/lifted/html-document.d.ts +1 -0
- package/dist/utils/lifted/html-document.js +12 -0
- package/dist/utils/lifted/languageOptions.d.ts +9 -0
- package/dist/utils/lifted/languageOptions.js +52 -0
- package/dist/utils/lifted/languages.d.ts +34 -0
- package/dist/utils/lifted/languages.js +175 -0
- package/dist/utils/lifted/loading-spinner.d.ts +18 -0
- package/dist/utils/lifted/loading-spinner.js +200 -0
- package/dist/utils/lifted/media-refs.d.ts +13 -0
- package/dist/utils/lifted/media-refs.js +27 -0
- package/dist/utils/lifted/scroll-root.d.ts +1 -0
- package/dist/utils/lifted/scroll-root.js +25 -0
- package/dist/utils/lifted/syntax-themes.d.ts +32 -0
- package/dist/utils/lifted/syntax-themes.js +100 -0
- package/dist/utils/lifted/url-utm.d.ts +24 -0
- package/dist/utils/lifted/url-utm.js +66 -0
- package/dist/utils/lifted/use-is-mounted.d.ts +24 -0
- package/dist/utils/lifted/use-is-mounted.js +21 -0
- package/dist/utils/lifted/useToastManager.d.ts +1 -0
- package/dist/utils/lifted/useToastManager.js +7 -0
- package/dist/utils/report-kind-at-raw-renderer.d.ts +19 -0
- package/dist/utils/report-kind-at-raw-renderer.js +32 -0
- package/package.json +32 -3
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { splitFrontmatter } from "../diagram-type.js";
|
|
2
|
+
import { MermaidOpError } from "../model/ops.js";
|
|
3
|
+
const HEADER_RE = /^stateDiagram(-v2)?\s*$/;
|
|
4
|
+
const TRANSITION_RE = /^(\[\*\]|\w+)\s*-->\s*(\[\*\]|\w+)\s*(?::\s*(.*))?$/;
|
|
5
|
+
const ALIAS_RE = /^state\s+"([^"]*)"\s+as\s+(\w+)\s*$/;
|
|
6
|
+
const DECL_RE = /^state\s+(\w+)\s*$/;
|
|
7
|
+
const DESC_RE = /^(\w+)\s*:\s*(.+)$/;
|
|
8
|
+
const BARE_RE = /^\w+$/;
|
|
9
|
+
const DIRECTION_RE = /^direction\s+\w+\s*$/;
|
|
10
|
+
function parse(source) {
|
|
11
|
+
const { bodyStartIndex, lines } = splitFrontmatter(source);
|
|
12
|
+
const doc = {
|
|
13
|
+
kind: "state",
|
|
14
|
+
diagramType: "state",
|
|
15
|
+
frontmatter: lines.slice(0, bodyStartIndex),
|
|
16
|
+
sourceLines: [],
|
|
17
|
+
warnings: [],
|
|
18
|
+
header: "stateDiagram-v2",
|
|
19
|
+
states: [],
|
|
20
|
+
transitions: []
|
|
21
|
+
};
|
|
22
|
+
const byId = /* @__PURE__ */ new Map();
|
|
23
|
+
const ensure = (id) => {
|
|
24
|
+
let node = byId.get(id);
|
|
25
|
+
if (!node) {
|
|
26
|
+
node = { id };
|
|
27
|
+
byId.set(id, node);
|
|
28
|
+
doc.states.push(node);
|
|
29
|
+
}
|
|
30
|
+
return node;
|
|
31
|
+
};
|
|
32
|
+
let headerSeen = false;
|
|
33
|
+
let counter = 0;
|
|
34
|
+
for (const rawLine of lines.slice(bodyStartIndex)) {
|
|
35
|
+
const trimmed = rawLine.trim();
|
|
36
|
+
if (!trimmed || trimmed.startsWith("%%")) {
|
|
37
|
+
doc.sourceLines.push({ text: rawLine });
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (!headerSeen) {
|
|
41
|
+
if (!HEADER_RE.test(trimmed)) {
|
|
42
|
+
return { status: "code-only", reason: "unrecognized state diagram header", diagnostics: [] };
|
|
43
|
+
}
|
|
44
|
+
headerSeen = true;
|
|
45
|
+
doc.header = trimmed;
|
|
46
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "header", id: "header" } });
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (trimmed.includes("{") || trimmed.includes("}") || trimmed.includes("<<") || trimmed === "--" || /^note\b/.test(trimmed)) {
|
|
50
|
+
return { status: "code-only", reason: "uses composite states, notes, or forks", diagnostics: [] };
|
|
51
|
+
}
|
|
52
|
+
if (DIRECTION_RE.test(trimmed)) {
|
|
53
|
+
doc.sourceLines.push({ text: rawLine });
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const tr = TRANSITION_RE.exec(trimmed);
|
|
57
|
+
if (tr) {
|
|
58
|
+
const from = tr[1];
|
|
59
|
+
const to = tr[2];
|
|
60
|
+
if (from !== "[*]") ensure(from);
|
|
61
|
+
if (to !== "[*]") ensure(to);
|
|
62
|
+
const t = {
|
|
63
|
+
id: `st${++counter}`,
|
|
64
|
+
from,
|
|
65
|
+
to,
|
|
66
|
+
label: tr[3]?.trim() || void 0,
|
|
67
|
+
raw: rawLine
|
|
68
|
+
};
|
|
69
|
+
doc.transitions.push(t);
|
|
70
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "transition", id: t.id } });
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const alias = ALIAS_RE.exec(trimmed);
|
|
74
|
+
if (alias) {
|
|
75
|
+
const node = ensure(alias[2]);
|
|
76
|
+
node.description = alias[1];
|
|
77
|
+
node.descForm = "alias";
|
|
78
|
+
node.hasLine = true;
|
|
79
|
+
node.raw = rawLine;
|
|
80
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "stateLine", id: node.id } });
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const decl = DECL_RE.exec(trimmed);
|
|
84
|
+
if (decl) {
|
|
85
|
+
const node = ensure(decl[1]);
|
|
86
|
+
node.hasLine = true;
|
|
87
|
+
node.raw = rawLine;
|
|
88
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "stateLine", id: node.id } });
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const desc = DESC_RE.exec(trimmed);
|
|
92
|
+
if (desc) {
|
|
93
|
+
const node = ensure(desc[1]);
|
|
94
|
+
node.description = desc[2].trim();
|
|
95
|
+
node.descForm = "colon";
|
|
96
|
+
node.hasLine = true;
|
|
97
|
+
node.raw = rawLine;
|
|
98
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "stateLine", id: node.id } });
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (BARE_RE.test(trimmed)) {
|
|
102
|
+
const node = ensure(trimmed);
|
|
103
|
+
node.hasLine = true;
|
|
104
|
+
node.raw = rawLine;
|
|
105
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "stateLine", id: node.id } });
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
status: "code-only",
|
|
110
|
+
reason: `unrecognized statement: "${trimmed.slice(0, 40)}"`,
|
|
111
|
+
diagnostics: []
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (!headerSeen) {
|
|
115
|
+
return { status: "invalid", diagnostics: [{ line: 1, message: "missing state diagram header", severity: "error" }] };
|
|
116
|
+
}
|
|
117
|
+
return { status: "ok", doc };
|
|
118
|
+
}
|
|
119
|
+
function stateLineText(node) {
|
|
120
|
+
if (node.description !== void 0) {
|
|
121
|
+
return node.descForm === "alias" ? `state "${node.description}" as ${node.id}` : `${node.id} : ${node.description}`;
|
|
122
|
+
}
|
|
123
|
+
return node.id;
|
|
124
|
+
}
|
|
125
|
+
function transitionLine(t) {
|
|
126
|
+
return t.label ? `${t.from} --> ${t.to} : ${t.label}` : `${t.from} --> ${t.to}`;
|
|
127
|
+
}
|
|
128
|
+
function serialize(doc) {
|
|
129
|
+
const out = [...doc.frontmatter];
|
|
130
|
+
const states = doc.states;
|
|
131
|
+
const stateById = new Map(states.map((s) => [s.id, s]));
|
|
132
|
+
const transitionById = new Map(doc.transitions.map((t) => [t.id, t]));
|
|
133
|
+
const emittedState = /* @__PURE__ */ new Set();
|
|
134
|
+
const emittedTransition = /* @__PURE__ */ new Set();
|
|
135
|
+
for (const line of doc.sourceLines) {
|
|
136
|
+
const indent = /^(\s*)/.exec(line.text)?.[1] ?? "";
|
|
137
|
+
if (!line.ref) {
|
|
138
|
+
out.push(line.text);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
switch (line.ref.entity) {
|
|
142
|
+
case "transition": {
|
|
143
|
+
const t = transitionById.get(line.ref.id);
|
|
144
|
+
if (!t) break;
|
|
145
|
+
emittedTransition.add(t.id);
|
|
146
|
+
out.push(t.dirty ? `${indent}${transitionLine(t)}` : line.text);
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
case "stateLine": {
|
|
150
|
+
const node = stateById.get(line.ref.id);
|
|
151
|
+
if (!node) break;
|
|
152
|
+
emittedState.add(node.id);
|
|
153
|
+
out.push(node.dirty ? `${indent}${stateLineText(node)}` : line.text);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
default:
|
|
157
|
+
out.push(line.text);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const additions = [];
|
|
161
|
+
for (const node of states) {
|
|
162
|
+
if (emittedState.has(node.id)) continue;
|
|
163
|
+
if (node.added || node.dirty && node.description !== void 0) {
|
|
164
|
+
additions.push(` ${stateLineText(node)}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
for (const t of doc.transitions) {
|
|
168
|
+
if (!emittedTransition.has(t.id) && !t.raw) additions.push(` ${transitionLine(t)}`);
|
|
169
|
+
}
|
|
170
|
+
return [...out, ...additions].join("\n");
|
|
171
|
+
}
|
|
172
|
+
function applyOp(doc, op) {
|
|
173
|
+
const next = structuredClone(doc);
|
|
174
|
+
const sop = op;
|
|
175
|
+
const findState = (id) => {
|
|
176
|
+
const s = next.states.find((x) => x.id === id);
|
|
177
|
+
if (!s) throw new MermaidOpError("That state no longer exists");
|
|
178
|
+
return s;
|
|
179
|
+
};
|
|
180
|
+
const findTransition = (id) => {
|
|
181
|
+
const t = next.transitions.find((x) => x.id === id);
|
|
182
|
+
if (!t) throw new MermaidOpError("That transition no longer exists");
|
|
183
|
+
return t;
|
|
184
|
+
};
|
|
185
|
+
switch (sop.type) {
|
|
186
|
+
case "addState": {
|
|
187
|
+
const id = sop.name.trim();
|
|
188
|
+
if (!/^\w+$/.test(id)) throw new MermaidOpError("State names must be a single word (letters, digits, _)");
|
|
189
|
+
if (next.states.some((s) => s.id === id)) throw new MermaidOpError("A state with that name already exists");
|
|
190
|
+
next.states.push({ id, added: true });
|
|
191
|
+
return next;
|
|
192
|
+
}
|
|
193
|
+
case "setStateDescription": {
|
|
194
|
+
const s = findState(sop.id);
|
|
195
|
+
s.description = sop.description || void 0;
|
|
196
|
+
s.dirty = true;
|
|
197
|
+
return next;
|
|
198
|
+
}
|
|
199
|
+
case "deleteState": {
|
|
200
|
+
findState(sop.id);
|
|
201
|
+
next.states = next.states.filter((s) => s.id !== sop.id);
|
|
202
|
+
next.transitions = next.transitions.filter((t) => t.from !== sop.id && t.to !== sop.id);
|
|
203
|
+
return next;
|
|
204
|
+
}
|
|
205
|
+
case "addTransition": {
|
|
206
|
+
next.transitions.push({
|
|
207
|
+
id: `st_a${next.transitions.length + 1}`,
|
|
208
|
+
from: sop.from,
|
|
209
|
+
to: sop.to,
|
|
210
|
+
label: sop.label?.trim() || void 0,
|
|
211
|
+
added: true
|
|
212
|
+
});
|
|
213
|
+
return next;
|
|
214
|
+
}
|
|
215
|
+
case "setTransitionLabel": {
|
|
216
|
+
const t = findTransition(sop.id);
|
|
217
|
+
t.label = sop.label.trim() || void 0;
|
|
218
|
+
t.dirty = true;
|
|
219
|
+
return next;
|
|
220
|
+
}
|
|
221
|
+
case "reverseTransition": {
|
|
222
|
+
const t = findTransition(sop.id);
|
|
223
|
+
[t.from, t.to] = [t.to, t.from];
|
|
224
|
+
t.dirty = true;
|
|
225
|
+
return next;
|
|
226
|
+
}
|
|
227
|
+
case "deleteTransition": {
|
|
228
|
+
findTransition(sop.id);
|
|
229
|
+
next.transitions = next.transitions.filter((t) => t.id !== sop.id);
|
|
230
|
+
return next;
|
|
231
|
+
}
|
|
232
|
+
default:
|
|
233
|
+
throw new MermaidOpError("Unsupported operation for state diagrams");
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const stateAdapter = {
|
|
237
|
+
diagramType: "state",
|
|
238
|
+
parse,
|
|
239
|
+
serialize,
|
|
240
|
+
applyOp,
|
|
241
|
+
vocabulary: { node: "State", addNode: "Add state", edge: "Transition" }
|
|
242
|
+
};
|
|
243
|
+
export {
|
|
244
|
+
stateAdapter
|
|
245
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeline adapter. Rows (`period : event : event`) and sections edit
|
|
3
|
+
* per-line; structural inserts/deletes regenerate the body wholesale
|
|
4
|
+
* (content-preserving, formatting-normalizing).
|
|
5
|
+
*/
|
|
6
|
+
import type { MermaidAdapter } from "../model/adapter.js";
|
|
7
|
+
import type { TimelineDoc } from "../model/types.js";
|
|
8
|
+
export declare const timelineAdapter: MermaidAdapter<TimelineDoc>;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { splitFrontmatter } from "../diagram-type.js";
|
|
2
|
+
import { MermaidOpError } from "../model/ops.js";
|
|
3
|
+
function parse(source) {
|
|
4
|
+
const { bodyStartIndex, lines } = splitFrontmatter(source);
|
|
5
|
+
const doc = {
|
|
6
|
+
kind: "timeline",
|
|
7
|
+
diagramType: "timeline",
|
|
8
|
+
frontmatter: lines.slice(0, bodyStartIndex),
|
|
9
|
+
sourceLines: [],
|
|
10
|
+
warnings: [],
|
|
11
|
+
sections: []
|
|
12
|
+
};
|
|
13
|
+
let headerSeen = false;
|
|
14
|
+
let counter = 0;
|
|
15
|
+
let sectionCounter = 0;
|
|
16
|
+
let currentSection = null;
|
|
17
|
+
let lastRow = null;
|
|
18
|
+
const implicitSection = () => {
|
|
19
|
+
if (!currentSection) {
|
|
20
|
+
currentSection = { id: `sec${++sectionCounter}`, rows: [] };
|
|
21
|
+
doc.sections.push(currentSection);
|
|
22
|
+
}
|
|
23
|
+
return currentSection;
|
|
24
|
+
};
|
|
25
|
+
for (const rawLine of lines.slice(bodyStartIndex)) {
|
|
26
|
+
const trimmed = rawLine.trim();
|
|
27
|
+
if (!trimmed || trimmed.startsWith("%%")) {
|
|
28
|
+
doc.sourceLines.push({ text: rawLine });
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (!headerSeen) {
|
|
32
|
+
if (!/^timeline\s*$/.test(trimmed)) {
|
|
33
|
+
return { status: "code-only", reason: "unrecognized timeline header", diagnostics: [] };
|
|
34
|
+
}
|
|
35
|
+
headerSeen = true;
|
|
36
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "header", id: "header" } });
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const title = /^title\s+(.+)$/.exec(trimmed);
|
|
40
|
+
if (title && doc.title === void 0) {
|
|
41
|
+
doc.title = title[1].trim();
|
|
42
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "title", id: "title" } });
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const section = /^section\s+(.+)$/.exec(trimmed);
|
|
46
|
+
if (section) {
|
|
47
|
+
currentSection = {
|
|
48
|
+
id: `sec${++sectionCounter}`,
|
|
49
|
+
title: section[1].trim(),
|
|
50
|
+
rows: [],
|
|
51
|
+
raw: rawLine
|
|
52
|
+
};
|
|
53
|
+
doc.sections.push(currentSection);
|
|
54
|
+
lastRow = null;
|
|
55
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "section", id: currentSection.id } });
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (trimmed.startsWith(":")) {
|
|
59
|
+
if (!lastRow) {
|
|
60
|
+
return { status: "code-only", reason: "event continuation with no period", diagnostics: [] };
|
|
61
|
+
}
|
|
62
|
+
const events = trimmed.split(":").map((e) => e.trim()).filter(Boolean);
|
|
63
|
+
lastRow.events.push(...events);
|
|
64
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "rowCont", id: lastRow.id } });
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (trimmed.includes(":")) {
|
|
68
|
+
const [period, ...events] = trimmed.split(":").map((p) => p.trim());
|
|
69
|
+
const row2 = {
|
|
70
|
+
id: `t${++counter}`,
|
|
71
|
+
period,
|
|
72
|
+
events: events.filter(Boolean),
|
|
73
|
+
raw: rawLine
|
|
74
|
+
};
|
|
75
|
+
implicitSection().rows.push(row2);
|
|
76
|
+
lastRow = row2;
|
|
77
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "row", id: row2.id } });
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const row = { id: `t${++counter}`, period: trimmed, events: [], raw: rawLine };
|
|
81
|
+
implicitSection().rows.push(row);
|
|
82
|
+
lastRow = row;
|
|
83
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "row", id: row.id } });
|
|
84
|
+
}
|
|
85
|
+
if (!headerSeen) {
|
|
86
|
+
return { status: "invalid", diagnostics: [{ line: 1, message: "missing timeline header", severity: "error" }] };
|
|
87
|
+
}
|
|
88
|
+
return { status: "ok", doc };
|
|
89
|
+
}
|
|
90
|
+
function rowLine(row) {
|
|
91
|
+
return row.events.length > 0 ? `${row.period} : ${row.events.join(" : ")}` : row.period;
|
|
92
|
+
}
|
|
93
|
+
function serialize(doc) {
|
|
94
|
+
const tdoc = doc;
|
|
95
|
+
const out = [...doc.frontmatter];
|
|
96
|
+
if (tdoc.regenerateAll) {
|
|
97
|
+
const comments = doc.sourceLines.filter((l) => !l.ref && l.text.trim().startsWith("%%")).map((l) => l.text);
|
|
98
|
+
out.push("timeline", ...comments);
|
|
99
|
+
if (doc.title !== void 0) out.push(` title ${doc.title}`);
|
|
100
|
+
for (const section of doc.sections) {
|
|
101
|
+
if (section.title !== void 0) out.push(` section ${section.title}`);
|
|
102
|
+
for (const row of section.rows) out.push(` ${rowLine(row)}`);
|
|
103
|
+
}
|
|
104
|
+
return out.join("\n");
|
|
105
|
+
}
|
|
106
|
+
const rowById = /* @__PURE__ */ new Map();
|
|
107
|
+
const sectionById = /* @__PURE__ */ new Map();
|
|
108
|
+
for (const section of doc.sections) {
|
|
109
|
+
sectionById.set(section.id, section);
|
|
110
|
+
for (const row of section.rows) rowById.set(row.id, row);
|
|
111
|
+
}
|
|
112
|
+
const emitted = /* @__PURE__ */ new Set();
|
|
113
|
+
for (const line of doc.sourceLines) {
|
|
114
|
+
const indent = /^(\s*)/.exec(line.text)?.[1] ?? "";
|
|
115
|
+
if (!line.ref) {
|
|
116
|
+
out.push(line.text);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
switch (line.ref.entity) {
|
|
120
|
+
case "title":
|
|
121
|
+
if (doc.title === void 0) break;
|
|
122
|
+
out.push(tdoc.dirtyTitle ? `${indent}title ${doc.title}` : line.text);
|
|
123
|
+
break;
|
|
124
|
+
case "section": {
|
|
125
|
+
const section = sectionById.get(line.ref.id);
|
|
126
|
+
if (!section) break;
|
|
127
|
+
out.push(section.dirty ? `${indent}section ${section.title ?? ""}` : line.text);
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case "row": {
|
|
131
|
+
const row = rowById.get(line.ref.id);
|
|
132
|
+
if (!row) break;
|
|
133
|
+
emitted.add(row.id);
|
|
134
|
+
out.push(row.dirty ? `${indent}${rowLine(row)}` : line.text);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
case "rowCont": {
|
|
138
|
+
const row = rowById.get(line.ref.id);
|
|
139
|
+
if (!row || row.dirty) break;
|
|
140
|
+
out.push(line.text);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
default:
|
|
144
|
+
out.push(line.text);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return out.join("\n");
|
|
148
|
+
}
|
|
149
|
+
function applyOp(doc, op) {
|
|
150
|
+
const next = structuredClone(doc);
|
|
151
|
+
const top = op;
|
|
152
|
+
const findRow = (id) => {
|
|
153
|
+
for (const section of next.sections) {
|
|
154
|
+
const row = section.rows.find((r) => r.id === id);
|
|
155
|
+
if (row) return row;
|
|
156
|
+
}
|
|
157
|
+
throw new MermaidOpError("That entry no longer exists");
|
|
158
|
+
};
|
|
159
|
+
const findSection = (id) => {
|
|
160
|
+
const s = next.sections.find((x) => x.id === id);
|
|
161
|
+
if (!s) throw new MermaidOpError("That section no longer exists");
|
|
162
|
+
return s;
|
|
163
|
+
};
|
|
164
|
+
switch (top.type) {
|
|
165
|
+
case "setTitle": {
|
|
166
|
+
next.title = top.title || void 0;
|
|
167
|
+
next.dirtyTitle = true;
|
|
168
|
+
if (!next.sourceLines.some((l) => l.ref?.entity === "title")) next.regenerateAll = true;
|
|
169
|
+
return next;
|
|
170
|
+
}
|
|
171
|
+
case "addSection": {
|
|
172
|
+
next.sections.push({ id: `sec_a${next.sections.length + 1}`, title: top.title, rows: [] });
|
|
173
|
+
next.regenerateAll = true;
|
|
174
|
+
return next;
|
|
175
|
+
}
|
|
176
|
+
case "renameSection": {
|
|
177
|
+
const s = findSection(top.id);
|
|
178
|
+
s.title = top.title;
|
|
179
|
+
s.dirty = true;
|
|
180
|
+
return next;
|
|
181
|
+
}
|
|
182
|
+
case "deleteSection": {
|
|
183
|
+
findSection(top.id);
|
|
184
|
+
next.sections = next.sections.filter((s) => s.id !== top.id);
|
|
185
|
+
next.regenerateAll = true;
|
|
186
|
+
return next;
|
|
187
|
+
}
|
|
188
|
+
case "addRow": {
|
|
189
|
+
const s = findSection(top.sectionId);
|
|
190
|
+
s.rows.push({
|
|
191
|
+
id: `t_a${s.rows.length + 1}`,
|
|
192
|
+
period: top.period,
|
|
193
|
+
events: top.event ? [top.event] : []
|
|
194
|
+
});
|
|
195
|
+
next.regenerateAll = true;
|
|
196
|
+
return next;
|
|
197
|
+
}
|
|
198
|
+
case "editRow": {
|
|
199
|
+
const row = findRow(top.id);
|
|
200
|
+
if (top.period !== void 0) row.period = top.period;
|
|
201
|
+
row.dirty = true;
|
|
202
|
+
return next;
|
|
203
|
+
}
|
|
204
|
+
case "addEvent": {
|
|
205
|
+
const row = findRow(top.rowId);
|
|
206
|
+
row.events.push(top.text);
|
|
207
|
+
row.dirty = true;
|
|
208
|
+
return next;
|
|
209
|
+
}
|
|
210
|
+
case "editEvent": {
|
|
211
|
+
const row = findRow(top.rowId);
|
|
212
|
+
if (top.eventIndex < 0 || top.eventIndex >= row.events.length) {
|
|
213
|
+
throw new MermaidOpError("That event no longer exists");
|
|
214
|
+
}
|
|
215
|
+
row.events[top.eventIndex] = top.text;
|
|
216
|
+
row.dirty = true;
|
|
217
|
+
return next;
|
|
218
|
+
}
|
|
219
|
+
case "deleteEvent": {
|
|
220
|
+
const row = findRow(top.rowId);
|
|
221
|
+
row.events.splice(top.eventIndex, 1);
|
|
222
|
+
row.dirty = true;
|
|
223
|
+
return next;
|
|
224
|
+
}
|
|
225
|
+
case "deleteRow": {
|
|
226
|
+
findRow(top.id);
|
|
227
|
+
for (const section of next.sections) {
|
|
228
|
+
section.rows = section.rows.filter((r) => r.id !== top.id);
|
|
229
|
+
}
|
|
230
|
+
return next;
|
|
231
|
+
}
|
|
232
|
+
default:
|
|
233
|
+
throw new MermaidOpError("Unsupported operation for timelines");
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const timelineAdapter = {
|
|
237
|
+
diagramType: "timeline",
|
|
238
|
+
parse,
|
|
239
|
+
serialize,
|
|
240
|
+
applyOp,
|
|
241
|
+
vocabulary: { node: "Entry", addNode: "Add entry" }
|
|
242
|
+
};
|
|
243
|
+
export {
|
|
244
|
+
timelineAdapter
|
|
245
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-diagram-type catalog — single source of truth for how each mermaid
|
|
3
|
+
* diagram type is PRESENTED to users as a distinct feature ("Flowchart",
|
|
4
|
+
* "Mind Map", "Sequence Diagram", …) while one backbone renders them all.
|
|
5
|
+
*
|
|
6
|
+
* Drives: block/canvas labels and icons, starter templates, the new-diagram
|
|
7
|
+
* picker, and which types support structural (visual/outline) editing.
|
|
8
|
+
*/
|
|
9
|
+
import type { LucideIcon } from "lucide-react";
|
|
10
|
+
import type { MermaidDiagramType } from "./diagram-type.js";
|
|
11
|
+
export type MermaidSupportLevel = "full" | "code-only";
|
|
12
|
+
export interface MermaidCatalogEntry {
|
|
13
|
+
/** User-facing feature name — never says "mermaid". */
|
|
14
|
+
label: string;
|
|
15
|
+
icon: LucideIcon;
|
|
16
|
+
description: string;
|
|
17
|
+
/** Complete, valid starter source for "create new". */
|
|
18
|
+
starterTemplate: string;
|
|
19
|
+
/**
|
|
20
|
+
* "full" → structural editing planned/available (visual + outline modes
|
|
21
|
+
* gate further on an adapter passing the round-trip fidelity check)
|
|
22
|
+
* "code-only" → render + code + AI editing only
|
|
23
|
+
*/
|
|
24
|
+
support: MermaidSupportLevel;
|
|
25
|
+
/** Featured types appear in the create-new picker. */
|
|
26
|
+
featured?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare const MERMAID_CATALOG: Record<MermaidDiagramType, MermaidCatalogEntry>;
|
|
29
|
+
export declare function getCatalogEntry(type: MermaidDiagramType): MermaidCatalogEntry;
|
|
30
|
+
/** Entries shown in the create-new picker, in catalog order. */
|
|
31
|
+
export declare function getFeaturedCatalogEntries(): Array<MermaidCatalogEntry & {
|
|
32
|
+
type: MermaidDiagramType;
|
|
33
|
+
}>;
|