@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,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMermaidPreferences } from "../host/app-bindings.js";
|
|
4
|
+
import { useThemeMode } from "../host/app-bindings.js";
|
|
5
|
+
import { MermaidRenderer } from "./MermaidRenderer.js";
|
|
6
|
+
import {
|
|
7
|
+
DEFAULT_MERMAID_PREFERENCES,
|
|
8
|
+
resolveMermaidTheme
|
|
9
|
+
} from "./types.js";
|
|
10
|
+
function MermaidView({
|
|
11
|
+
source,
|
|
12
|
+
metadata,
|
|
13
|
+
isStreamActive,
|
|
14
|
+
className,
|
|
15
|
+
hideViewportControls,
|
|
16
|
+
onSvgMounted,
|
|
17
|
+
viewportMaxHeight,
|
|
18
|
+
fillHeight
|
|
19
|
+
}) {
|
|
20
|
+
const prefs = { ...DEFAULT_MERMAID_PREFERENCES, ...useMermaidPreferences() };
|
|
21
|
+
const appMode = useThemeMode();
|
|
22
|
+
const options = {
|
|
23
|
+
theme: resolveMermaidTheme(metadata?.theme ?? prefs.theme, appMode),
|
|
24
|
+
look: metadata?.look ?? prefs.look,
|
|
25
|
+
layout: metadata?.layout ?? prefs.layout
|
|
26
|
+
};
|
|
27
|
+
return /* @__PURE__ */ jsx(
|
|
28
|
+
MermaidRenderer,
|
|
29
|
+
{
|
|
30
|
+
source,
|
|
31
|
+
options,
|
|
32
|
+
isStreamActive,
|
|
33
|
+
className,
|
|
34
|
+
hideViewportControls,
|
|
35
|
+
onSvgMounted,
|
|
36
|
+
viewportMaxHeight,
|
|
37
|
+
fillHeight
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
function StandaloneMermaidView({
|
|
42
|
+
source,
|
|
43
|
+
metadata,
|
|
44
|
+
className,
|
|
45
|
+
viewportMaxHeight,
|
|
46
|
+
fillHeight
|
|
47
|
+
}) {
|
|
48
|
+
const mode = useThemeMode();
|
|
49
|
+
const options = {
|
|
50
|
+
theme: resolveMermaidTheme(metadata?.theme ?? DEFAULT_MERMAID_PREFERENCES.theme, mode),
|
|
51
|
+
look: metadata?.look ?? DEFAULT_MERMAID_PREFERENCES.look,
|
|
52
|
+
layout: metadata?.layout ?? DEFAULT_MERMAID_PREFERENCES.layout
|
|
53
|
+
};
|
|
54
|
+
return /* @__PURE__ */ jsx(
|
|
55
|
+
MermaidRenderer,
|
|
56
|
+
{
|
|
57
|
+
source,
|
|
58
|
+
options,
|
|
59
|
+
className,
|
|
60
|
+
viewportMaxHeight,
|
|
61
|
+
fillHeight
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
MermaidView,
|
|
67
|
+
StandaloneMermaidView
|
|
68
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded, fit-aware pan/zoom viewport for a rendered mermaid SVG.
|
|
3
|
+
*
|
|
4
|
+
* The sizing problem this solves: a diagram has its own intrinsic aspect ratio,
|
|
5
|
+
* and naively fitting it to the container width either runs off the screen
|
|
6
|
+
* vertically (tall flowcharts) or shrinks the text to nothing (wide mind maps).
|
|
7
|
+
*
|
|
8
|
+
* The fix is THE DIAGRAM'S FIT RULE (`canvas-adaptive.ts`, one floor for both):
|
|
9
|
+
* - Fit the WHOLE drawing when that scale keeps text readable
|
|
10
|
+
* (≥ `DIAGRAM_READABLE_ZOOM`, 14px text at ≥ 10px) — a 1648px flowchart in
|
|
11
|
+
* a 1370px pane fits whole at ~0.83 instead of overflowing sideways.
|
|
12
|
+
* - Otherwise fit the WIDTH, never below that floor; the view starts at the
|
|
13
|
+
* top-left and the rest is reached by scrolling / panning.
|
|
14
|
+
* - Never auto-upscale past natural (`MAX_FIT`) — that just blurs and wastes
|
|
15
|
+
* space; the user can zoom in deliberately.
|
|
16
|
+
*
|
|
17
|
+
* Scaling is applied as explicit pixel width/height on the SVG (vector-crisp,
|
|
18
|
+
* gives the scroll container real content, and keeps `getScreenCTM()` honest so
|
|
19
|
+
* visual-mode hit-testing stays accurate). Manual zoom (ctrl/cmd-wheel, pinch,
|
|
20
|
+
* buttons) overrides the auto-fit until the user hits "Fit" again. Plain wheel
|
|
21
|
+
* scrolls — an embedded diagram must never hijack page scroll.
|
|
22
|
+
*/
|
|
23
|
+
import React from "react";
|
|
24
|
+
interface FrameBox {
|
|
25
|
+
w: number;
|
|
26
|
+
h: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Whether a frame resize re-fits the diagram. The pane growing (Expand,
|
|
30
|
+
* unsplit) or shrinking re-fits unless the person zoomed or panned by hand
|
|
31
|
+
* since the last fit — their view is theirs. A frame whose height follows its
|
|
32
|
+
* content (not `fillHeight`) re-fits on WIDTH only: fitting changes the
|
|
33
|
+
* content height, which would change the frame height and oscillate.
|
|
34
|
+
*/
|
|
35
|
+
export declare function shouldRefitOnResize(input: {
|
|
36
|
+
previous: FrameBox | null;
|
|
37
|
+
next: FrameBox;
|
|
38
|
+
fillHeight: boolean;
|
|
39
|
+
userAdjusted: boolean;
|
|
40
|
+
fitPending: boolean;
|
|
41
|
+
}): boolean;
|
|
42
|
+
interface NaturalSize {
|
|
43
|
+
w: number;
|
|
44
|
+
h: number;
|
|
45
|
+
}
|
|
46
|
+
export interface MermaidFit {
|
|
47
|
+
scale: number;
|
|
48
|
+
/** The whole drawing fits; false = width fit at the floor, view at top-left. */
|
|
49
|
+
whole: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* THE diagram fit rule (same floor as `portraitWidthFitViewport`): fit the
|
|
53
|
+
* whole drawing when that scale is readable, else fit the width down to the
|
|
54
|
+
* readable floor. `fh` is `Infinity` for a frame with no height bound.
|
|
55
|
+
*/
|
|
56
|
+
export declare function mermaidFitScale(nat: NaturalSize, fw: number, fh: number): MermaidFit;
|
|
57
|
+
interface MermaidViewportProps {
|
|
58
|
+
/** Rendered SVG markup (sanitized by mermaid under securityLevel strict). */
|
|
59
|
+
svg: string;
|
|
60
|
+
className?: string;
|
|
61
|
+
/** Hide the zoom controls (e.g. tiny inline contexts, popover-open states). */
|
|
62
|
+
hideControls?: boolean;
|
|
63
|
+
/** Receives the live SVG element after each injection (visual-mode hook). */
|
|
64
|
+
onSvgMounted?: (el: SVGSVGElement | null) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Px cap on the frame height (chat/inline contexts). The diagram fits within
|
|
67
|
+
* this height and scrolls past it. Omit + set `fillHeight` for surfaces that
|
|
68
|
+
* already bound height (canvas workbench, fullscreen).
|
|
69
|
+
*/
|
|
70
|
+
maxFrameHeight?: number;
|
|
71
|
+
/** Frame fills its parent's height and fits to the measured height. */
|
|
72
|
+
fillHeight?: boolean;
|
|
73
|
+
}
|
|
74
|
+
export declare function MermaidViewport({ svg, className, hideControls, onSvgMounted, maxFrameHeight, fillHeight, }: MermaidViewportProps): React.JSX.Element;
|
|
75
|
+
export {};
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { Maximize, Minus, Plus, Scan } from "lucide-react";
|
|
5
|
+
import { DIAGRAM_READABLE_ZOOM } from "../display/blocks/canvas-adaptive.js";
|
|
6
|
+
import { SimpleTooltip } from "../utils/lifted/Tooltip.js";
|
|
7
|
+
import { cn } from "@ai-matrx/design-system";
|
|
8
|
+
const MAX_FIT = 1;
|
|
9
|
+
const MIN_SCALE = 0.1;
|
|
10
|
+
const MAX_SCALE = 8;
|
|
11
|
+
const ZOOM_STEP = 1.25;
|
|
12
|
+
const FRAME_PADDING = 16;
|
|
13
|
+
function shouldRefitOnResize(input) {
|
|
14
|
+
const { previous, next, fillHeight, userAdjusted, fitPending } = input;
|
|
15
|
+
if (userAdjusted) return false;
|
|
16
|
+
if (fitPending || !previous) return true;
|
|
17
|
+
if (next.w !== previous.w) return true;
|
|
18
|
+
return fillHeight && next.h !== previous.h;
|
|
19
|
+
}
|
|
20
|
+
function mermaidFitScale(nat, fw, fh) {
|
|
21
|
+
if (!nat.w || !nat.h || !(fw > 0) || !(fh > 0)) return { scale: 1, whole: true };
|
|
22
|
+
const whole = Math.min(MAX_FIT, fw / nat.w, fh / nat.h);
|
|
23
|
+
if (whole >= DIAGRAM_READABLE_ZOOM) return { scale: whole, whole: true };
|
|
24
|
+
return {
|
|
25
|
+
scale: Math.min(MAX_FIT, Math.max(DIAGRAM_READABLE_ZOOM, fw / nat.w)),
|
|
26
|
+
whole: false
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function MermaidViewport({
|
|
30
|
+
svg,
|
|
31
|
+
className,
|
|
32
|
+
hideControls,
|
|
33
|
+
onSvgMounted,
|
|
34
|
+
maxFrameHeight,
|
|
35
|
+
fillHeight
|
|
36
|
+
}) {
|
|
37
|
+
const frameRef = useRef(null);
|
|
38
|
+
const hostRef = useRef(null);
|
|
39
|
+
const svgRef = useRef(null);
|
|
40
|
+
const naturalRef = useRef(null);
|
|
41
|
+
const userAdjustedRef = useRef(false);
|
|
42
|
+
const frameBoxRef = useRef(null);
|
|
43
|
+
const fitPendingRef = useRef(false);
|
|
44
|
+
const [scale, setScale] = useState(1);
|
|
45
|
+
const [canPan, setCanPan] = useState(false);
|
|
46
|
+
const dragRef = useRef(null);
|
|
47
|
+
const pointersRef = useRef(/* @__PURE__ */ new Map());
|
|
48
|
+
const pinchRef = useRef(null);
|
|
49
|
+
const frameSize = useCallback(() => {
|
|
50
|
+
const box = frameBoxRef.current ?? { w: 0, h: 0 };
|
|
51
|
+
const fw = box.w - FRAME_PADDING;
|
|
52
|
+
const bound = maxFrameHeight ?? (fillHeight ? box.h : Infinity);
|
|
53
|
+
return { fw: Math.max(0, fw), fh: Math.max(0, bound - FRAME_PADDING) };
|
|
54
|
+
}, [maxFrameHeight, fillHeight]);
|
|
55
|
+
const applyScale = useCallback((s) => {
|
|
56
|
+
const el = svgRef.current;
|
|
57
|
+
const nat = naturalRef.current;
|
|
58
|
+
if (!el || !nat) return;
|
|
59
|
+
el.style.maxWidth = "none";
|
|
60
|
+
el.style.width = `${Math.round(nat.w * s)}px`;
|
|
61
|
+
el.style.height = `${Math.round(nat.h * s)}px`;
|
|
62
|
+
}, []);
|
|
63
|
+
const fit = useCallback(() => {
|
|
64
|
+
const nat = naturalRef.current;
|
|
65
|
+
if (!nat) return;
|
|
66
|
+
const { fw, fh } = frameSize();
|
|
67
|
+
const { scale: s, whole } = mermaidFitScale(nat, fw, fh);
|
|
68
|
+
userAdjustedRef.current = false;
|
|
69
|
+
applyScale(s);
|
|
70
|
+
setScale(s);
|
|
71
|
+
const frame = frameRef.current;
|
|
72
|
+
if (!whole && frame) {
|
|
73
|
+
frame.scrollLeft = 0;
|
|
74
|
+
frame.scrollTop = 0;
|
|
75
|
+
}
|
|
76
|
+
}, [frameSize, applyScale]);
|
|
77
|
+
const oneToOne = useCallback(() => {
|
|
78
|
+
userAdjustedRef.current = true;
|
|
79
|
+
setScale(1);
|
|
80
|
+
}, []);
|
|
81
|
+
const clampScale = (s) => Math.min(MAX_SCALE, Math.max(MIN_SCALE, s));
|
|
82
|
+
const zoomBy = useCallback((factor) => {
|
|
83
|
+
userAdjustedRef.current = true;
|
|
84
|
+
setScale((s) => clampScale(s * factor));
|
|
85
|
+
}, []);
|
|
86
|
+
const fitRef = useRef(fit);
|
|
87
|
+
const applyScaleRef = useRef(applyScale);
|
|
88
|
+
const scaleRef = useRef(scale);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
fitRef.current = fit;
|
|
91
|
+
applyScaleRef.current = applyScale;
|
|
92
|
+
scaleRef.current = scale;
|
|
93
|
+
});
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
const host = hostRef.current;
|
|
96
|
+
if (!host) return void 0;
|
|
97
|
+
host.innerHTML = svg;
|
|
98
|
+
const el = host.querySelector("svg");
|
|
99
|
+
svgRef.current = el;
|
|
100
|
+
if (el) {
|
|
101
|
+
el.style.display = "block";
|
|
102
|
+
const vb = el.viewBox?.baseVal;
|
|
103
|
+
let nat = vb && vb.width && vb.height ? { w: vb.width, h: vb.height } : null;
|
|
104
|
+
if (!nat) {
|
|
105
|
+
try {
|
|
106
|
+
const bb = el.getBBox();
|
|
107
|
+
if (bb.width && bb.height) nat = { w: bb.width, h: bb.height };
|
|
108
|
+
} catch {
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
naturalRef.current = nat;
|
|
112
|
+
} else {
|
|
113
|
+
naturalRef.current = null;
|
|
114
|
+
}
|
|
115
|
+
onSvgMounted?.(el);
|
|
116
|
+
if (userAdjustedRef.current) applyScaleRef.current(scaleRef.current);
|
|
117
|
+
else if (frameBoxRef.current) fitRef.current();
|
|
118
|
+
else fitPendingRef.current = true;
|
|
119
|
+
return () => {
|
|
120
|
+
onSvgMounted?.(null);
|
|
121
|
+
};
|
|
122
|
+
}, [svg, onSvgMounted]);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
applyScale(scale);
|
|
125
|
+
}, [scale, applyScale]);
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
const frame = frameRef.current;
|
|
128
|
+
const host = hostRef.current;
|
|
129
|
+
if (!frame || !host || typeof ResizeObserver === "undefined")
|
|
130
|
+
return void 0;
|
|
131
|
+
const ro = new ResizeObserver(() => {
|
|
132
|
+
setCanPan(
|
|
133
|
+
frame.scrollWidth > frame.clientWidth + 1 || frame.scrollHeight > frame.clientHeight + 1
|
|
134
|
+
);
|
|
135
|
+
});
|
|
136
|
+
ro.observe(host);
|
|
137
|
+
return () => ro.disconnect();
|
|
138
|
+
}, []);
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
const frame = frameRef.current;
|
|
141
|
+
if (!frame || typeof ResizeObserver === "undefined") return void 0;
|
|
142
|
+
const ro = new ResizeObserver(() => {
|
|
143
|
+
const next = { w: frame.clientWidth, h: frame.clientHeight };
|
|
144
|
+
const previous = frameBoxRef.current;
|
|
145
|
+
frameBoxRef.current = next;
|
|
146
|
+
const refit = shouldRefitOnResize({
|
|
147
|
+
previous,
|
|
148
|
+
next,
|
|
149
|
+
fillHeight: Boolean(fillHeight),
|
|
150
|
+
userAdjusted: userAdjustedRef.current,
|
|
151
|
+
fitPending: fitPendingRef.current
|
|
152
|
+
});
|
|
153
|
+
fitPendingRef.current = false;
|
|
154
|
+
if (refit) fit();
|
|
155
|
+
});
|
|
156
|
+
ro.observe(frame);
|
|
157
|
+
return () => ro.disconnect();
|
|
158
|
+
}, [fit, fillHeight]);
|
|
159
|
+
const onWheel = (e) => {
|
|
160
|
+
if (!e.ctrlKey && !e.metaKey) return;
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
zoomBy(e.deltaY < 0 ? 1.1 : 1 / 1.1);
|
|
163
|
+
};
|
|
164
|
+
const onPointerDown = (e) => {
|
|
165
|
+
pointersRef.current.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
166
|
+
if (pointersRef.current.size === 2) {
|
|
167
|
+
const [a, b] = [...pointersRef.current.values()];
|
|
168
|
+
pinchRef.current = { distance: Math.hypot(a.x - b.x, a.y - b.y), scale };
|
|
169
|
+
dragRef.current = null;
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (e.button !== 0) return;
|
|
173
|
+
const frame = frameRef.current;
|
|
174
|
+
if (!frame) return;
|
|
175
|
+
dragRef.current = {
|
|
176
|
+
x: e.clientX,
|
|
177
|
+
y: e.clientY,
|
|
178
|
+
left: frame.scrollLeft,
|
|
179
|
+
top: frame.scrollTop
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
const onPointerMove = (e) => {
|
|
183
|
+
if (pointersRef.current.has(e.pointerId)) {
|
|
184
|
+
pointersRef.current.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
185
|
+
}
|
|
186
|
+
if (pinchRef.current && pointersRef.current.size === 2) {
|
|
187
|
+
const [a, b] = [...pointersRef.current.values()];
|
|
188
|
+
const distance = Math.hypot(a.x - b.x, a.y - b.y);
|
|
189
|
+
const ratio = distance / pinchRef.current.distance;
|
|
190
|
+
userAdjustedRef.current = true;
|
|
191
|
+
setScale(clampScale(pinchRef.current.scale * ratio));
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const drag = dragRef.current;
|
|
195
|
+
const frame = frameRef.current;
|
|
196
|
+
if (!drag || !frame) return;
|
|
197
|
+
frame.scrollLeft = drag.left - (e.clientX - drag.x);
|
|
198
|
+
frame.scrollTop = drag.top - (e.clientY - drag.y);
|
|
199
|
+
if (frame.scrollLeft !== drag.left || frame.scrollTop !== drag.top) {
|
|
200
|
+
userAdjustedRef.current = true;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
const onPointerUp = (e) => {
|
|
204
|
+
pointersRef.current.delete(e.pointerId);
|
|
205
|
+
if (pointersRef.current.size < 2) pinchRef.current = null;
|
|
206
|
+
dragRef.current = null;
|
|
207
|
+
};
|
|
208
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("group/viewport relative", className), children: [
|
|
209
|
+
/* @__PURE__ */ jsx(
|
|
210
|
+
"div",
|
|
211
|
+
{
|
|
212
|
+
ref: frameRef,
|
|
213
|
+
className: cn(
|
|
214
|
+
// 🚨 The page scrolls over a diagram. `overscroll-contain` plus a
|
|
215
|
+
// vertical scroller here swallowed the mouse wheel wherever a
|
|
216
|
+
// diagram rendered (verifier round 2). Vertically the diagram is
|
|
217
|
+
// fitted, so it needs no wheel scroll: a zoomed diagram pans by drag
|
|
218
|
+
// (which sets scrollTop directly) and zooms with ctrl/cmd-wheel.
|
|
219
|
+
// Only a full-height viewer (full screen) owns vertical scrolling.
|
|
220
|
+
fillHeight ? "h-full overflow-auto" : "overflow-x-auto overflow-y-hidden",
|
|
221
|
+
canPan ? "cursor-grab active:cursor-grabbing" : "cursor-default"
|
|
222
|
+
),
|
|
223
|
+
style: maxFrameHeight ? { maxHeight: maxFrameHeight } : void 0,
|
|
224
|
+
onWheel,
|
|
225
|
+
onPointerDown,
|
|
226
|
+
onPointerMove,
|
|
227
|
+
onPointerUp,
|
|
228
|
+
onPointerCancel: onPointerUp,
|
|
229
|
+
onDoubleClick: fit,
|
|
230
|
+
children: /* @__PURE__ */ jsx("div", { className: "flex min-h-full min-w-full touch-none select-none items-center-safe justify-center-safe p-2", children: /* @__PURE__ */ jsx("div", { ref: hostRef, className: "shrink-0" }) })
|
|
231
|
+
}
|
|
232
|
+
),
|
|
233
|
+
!hideControls && /* @__PURE__ */ jsxs("div", { className: "pointer-events-auto absolute bottom-2 right-2 z-10 flex items-center gap-0.5 rounded-md border border-border bg-card/90 p-0.5 opacity-100 shadow-sm backdrop-blur-sm transition-opacity sm:opacity-70 sm:group-hover/viewport:opacity-100 focus-within:opacity-100", children: [
|
|
234
|
+
/* @__PURE__ */ jsx(SimpleTooltip, { text: "Zoom out", children: /* @__PURE__ */ jsx(
|
|
235
|
+
"button",
|
|
236
|
+
{
|
|
237
|
+
type: "button",
|
|
238
|
+
"aria-label": "Zoom out",
|
|
239
|
+
className: "flex h-11 w-11 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground sm:h-auto sm:w-auto sm:p-1.5",
|
|
240
|
+
onClick: () => zoomBy(1 / ZOOM_STEP),
|
|
241
|
+
children: /* @__PURE__ */ jsx(Minus, { className: "h-3.5 w-3.5" })
|
|
242
|
+
}
|
|
243
|
+
) }),
|
|
244
|
+
/* @__PURE__ */ jsxs("span", { className: "flex h-11 min-w-11 items-center justify-center text-center text-[11px] tabular-nums text-muted-foreground sm:h-auto", children: [
|
|
245
|
+
Math.round(scale * 100),
|
|
246
|
+
"%"
|
|
247
|
+
] }),
|
|
248
|
+
/* @__PURE__ */ jsx(SimpleTooltip, { text: "Zoom in", children: /* @__PURE__ */ jsx(
|
|
249
|
+
"button",
|
|
250
|
+
{
|
|
251
|
+
type: "button",
|
|
252
|
+
"aria-label": "Zoom in",
|
|
253
|
+
className: "flex h-11 w-11 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground sm:h-auto sm:w-auto sm:p-1.5",
|
|
254
|
+
onClick: () => zoomBy(ZOOM_STEP),
|
|
255
|
+
children: /* @__PURE__ */ jsx(Plus, { className: "h-3.5 w-3.5" })
|
|
256
|
+
}
|
|
257
|
+
) }),
|
|
258
|
+
/* @__PURE__ */ jsx("span", { className: "mx-0.5 h-4 w-px bg-border" }),
|
|
259
|
+
/* @__PURE__ */ jsx(SimpleTooltip, { text: "Fit to view (double-click)", children: /* @__PURE__ */ jsx(
|
|
260
|
+
"button",
|
|
261
|
+
{
|
|
262
|
+
type: "button",
|
|
263
|
+
"aria-label": "Fit to view",
|
|
264
|
+
className: "flex h-11 w-11 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground sm:h-auto sm:w-auto sm:p-1.5",
|
|
265
|
+
onClick: fit,
|
|
266
|
+
children: /* @__PURE__ */ jsx(Scan, { className: "h-3.5 w-3.5" })
|
|
267
|
+
}
|
|
268
|
+
) }),
|
|
269
|
+
/* @__PURE__ */ jsx(SimpleTooltip, { text: "Actual size (100%)", children: /* @__PURE__ */ jsx(
|
|
270
|
+
"button",
|
|
271
|
+
{
|
|
272
|
+
type: "button",
|
|
273
|
+
"aria-label": "Actual size",
|
|
274
|
+
className: "flex h-11 w-11 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground sm:h-auto sm:w-auto sm:p-1.5",
|
|
275
|
+
onClick: oneToOne,
|
|
276
|
+
children: /* @__PURE__ */ jsx(Maximize, { className: "h-3.5 w-3.5" })
|
|
277
|
+
}
|
|
278
|
+
) })
|
|
279
|
+
] })
|
|
280
|
+
] });
|
|
281
|
+
}
|
|
282
|
+
export {
|
|
283
|
+
MermaidViewport,
|
|
284
|
+
mermaidFitScale,
|
|
285
|
+
shouldRefitOnResize
|
|
286
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entity-relationship adapter. Relationships (`A ||--o{ B : label`) are fully
|
|
3
|
+
* structurally editable (cardinality, label, reverse, delete, add). Entity
|
|
4
|
+
* attribute blocks (`ENTITY { … }`) are recognized and re-emitted verbatim —
|
|
5
|
+
* entities are listed but their attributes are edited in Code mode. An unclosed
|
|
6
|
+
* block or any unrecognized statement downgrades to code-only.
|
|
7
|
+
*/
|
|
8
|
+
import type { MermaidAdapter } from "../model/adapter.js";
|
|
9
|
+
import type { ErDoc } from "../model/types.js";
|
|
10
|
+
export declare const erAdapter: MermaidAdapter<ErDoc>;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { splitFrontmatter } from "../diagram-type.js";
|
|
2
|
+
import { MermaidOpError } from "../model/ops.js";
|
|
3
|
+
const ENTITY = `("[^"]*"|[\\w-]+)`;
|
|
4
|
+
const REL_RE = new RegExp(`^${ENTITY}\\s+([|o}{]{2})(--|\\.\\.)([|o}{]{2})\\s+${ENTITY}\\s*:\\s*(.*)$`);
|
|
5
|
+
const BLOCK_OPEN_RE = new RegExp(`^${ENTITY}\\s*\\{\\s*$`);
|
|
6
|
+
const DIRECTION_RE = /^direction\s+\w+\s*$/;
|
|
7
|
+
function stripQuotes(s) {
|
|
8
|
+
return s.startsWith('"') && s.endsWith('"') ? s.slice(1, -1) : s;
|
|
9
|
+
}
|
|
10
|
+
function parse(source) {
|
|
11
|
+
const { bodyStartIndex, lines } = splitFrontmatter(source);
|
|
12
|
+
const doc = {
|
|
13
|
+
kind: "er",
|
|
14
|
+
diagramType: "er",
|
|
15
|
+
frontmatter: lines.slice(0, bodyStartIndex),
|
|
16
|
+
sourceLines: [],
|
|
17
|
+
warnings: [],
|
|
18
|
+
entities: [],
|
|
19
|
+
relationships: []
|
|
20
|
+
};
|
|
21
|
+
const byId = /* @__PURE__ */ new Map();
|
|
22
|
+
const ensure = (id) => {
|
|
23
|
+
let e = byId.get(id);
|
|
24
|
+
if (!e) {
|
|
25
|
+
e = { id };
|
|
26
|
+
byId.set(id, e);
|
|
27
|
+
doc.entities.push(e);
|
|
28
|
+
}
|
|
29
|
+
return e;
|
|
30
|
+
};
|
|
31
|
+
const body = lines.slice(bodyStartIndex);
|
|
32
|
+
let headerSeen = false;
|
|
33
|
+
let counter = 0;
|
|
34
|
+
for (let i = 0; i < body.length; i++) {
|
|
35
|
+
const rawLine = body[i];
|
|
36
|
+
const trimmed = rawLine.trim();
|
|
37
|
+
if (!trimmed || trimmed.startsWith("%%")) {
|
|
38
|
+
doc.sourceLines.push({ text: rawLine });
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (!headerSeen) {
|
|
42
|
+
if (!/^erDiagram\s*$/.test(trimmed)) {
|
|
43
|
+
return { status: "code-only", reason: "unrecognized ER header", diagnostics: [] };
|
|
44
|
+
}
|
|
45
|
+
headerSeen = true;
|
|
46
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "header", id: "header" } });
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (DIRECTION_RE.test(trimmed)) {
|
|
50
|
+
doc.sourceLines.push({ text: rawLine });
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const rel = REL_RE.exec(trimmed);
|
|
54
|
+
if (rel) {
|
|
55
|
+
ensure(rel[1]);
|
|
56
|
+
ensure(rel[5]);
|
|
57
|
+
const r = {
|
|
58
|
+
id: `r${++counter}`,
|
|
59
|
+
left: rel[1],
|
|
60
|
+
right: rel[5],
|
|
61
|
+
leftCard: rel[2],
|
|
62
|
+
rightCard: rel[4],
|
|
63
|
+
identifying: rel[3] === "--",
|
|
64
|
+
label: stripQuotes(rel[6].trim()),
|
|
65
|
+
raw: rawLine
|
|
66
|
+
};
|
|
67
|
+
doc.relationships.push(r);
|
|
68
|
+
doc.sourceLines.push({ text: rawLine, ref: { entity: "rel", id: r.id } });
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const block = BLOCK_OPEN_RE.exec(trimmed);
|
|
72
|
+
if (block) {
|
|
73
|
+
const blockLines = [rawLine];
|
|
74
|
+
let closed = false;
|
|
75
|
+
while (i + 1 < body.length) {
|
|
76
|
+
i++;
|
|
77
|
+
blockLines.push(body[i]);
|
|
78
|
+
if (body[i].trim() === "}") {
|
|
79
|
+
closed = true;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (!closed) {
|
|
84
|
+
return { status: "code-only", reason: "unclosed entity block", diagnostics: [] };
|
|
85
|
+
}
|
|
86
|
+
const e = ensure(block[1]);
|
|
87
|
+
e.blockRaw = blockLines;
|
|
88
|
+
for (const bl of blockLines) doc.sourceLines.push({ text: bl });
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
status: "code-only",
|
|
93
|
+
reason: `unrecognized statement: "${trimmed.slice(0, 40)}"`,
|
|
94
|
+
diagnostics: []
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (!headerSeen) {
|
|
98
|
+
return { status: "invalid", diagnostics: [{ line: 1, message: "missing erDiagram header", severity: "error" }] };
|
|
99
|
+
}
|
|
100
|
+
return { status: "ok", doc };
|
|
101
|
+
}
|
|
102
|
+
function emitLabel(label) {
|
|
103
|
+
if (label === "") return '""';
|
|
104
|
+
return /[\s:]/.test(label) ? `"${label.replace(/"/g, "'")}"` : label;
|
|
105
|
+
}
|
|
106
|
+
function relationshipLine(r) {
|
|
107
|
+
const line = r.identifying ? "--" : "..";
|
|
108
|
+
return `${r.left} ${r.leftCard}${line}${r.rightCard} ${r.right} : ${emitLabel(r.label)}`;
|
|
109
|
+
}
|
|
110
|
+
function serialize(doc) {
|
|
111
|
+
const out = [...doc.frontmatter];
|
|
112
|
+
const relById = new Map(doc.relationships.map((r) => [r.id, r]));
|
|
113
|
+
const emitted = /* @__PURE__ */ new Set();
|
|
114
|
+
for (const line of doc.sourceLines) {
|
|
115
|
+
const indent = /^(\s*)/.exec(line.text)?.[1] ?? "";
|
|
116
|
+
if (!line.ref) {
|
|
117
|
+
out.push(line.text);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (line.ref.entity === "rel") {
|
|
121
|
+
const r = relById.get(line.ref.id);
|
|
122
|
+
if (!r) continue;
|
|
123
|
+
emitted.add(r.id);
|
|
124
|
+
out.push(r.dirty ? `${indent}${relationshipLine(r)}` : line.text);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
out.push(line.text);
|
|
128
|
+
}
|
|
129
|
+
const additions = [];
|
|
130
|
+
for (const r of doc.relationships) {
|
|
131
|
+
if (!emitted.has(r.id) && !r.raw) additions.push(` ${relationshipLine(r)}`);
|
|
132
|
+
}
|
|
133
|
+
return [...out, ...additions].join("\n");
|
|
134
|
+
}
|
|
135
|
+
function mirrorCard(token) {
|
|
136
|
+
return token.split("").reverse().map((c) => c === "{" ? "}" : c === "}" ? "{" : c).join("");
|
|
137
|
+
}
|
|
138
|
+
function applyOp(doc, op) {
|
|
139
|
+
const next = structuredClone(doc);
|
|
140
|
+
const eop = op;
|
|
141
|
+
const findRel = (id) => {
|
|
142
|
+
const r = next.relationships.find((x) => x.id === id);
|
|
143
|
+
if (!r) throw new MermaidOpError("That relationship no longer exists");
|
|
144
|
+
return r;
|
|
145
|
+
};
|
|
146
|
+
switch (eop.type) {
|
|
147
|
+
case "addRelationship": {
|
|
148
|
+
if (!next.entities.some((e) => e.id === eop.left) || !next.entities.some((e) => e.id === eop.right)) {
|
|
149
|
+
throw new MermaidOpError("Both entities must already exist");
|
|
150
|
+
}
|
|
151
|
+
next.relationships.push({
|
|
152
|
+
id: `r_a${next.relationships.length + 1}`,
|
|
153
|
+
left: eop.left,
|
|
154
|
+
right: eop.right,
|
|
155
|
+
leftCard: "||",
|
|
156
|
+
rightCard: "o{",
|
|
157
|
+
identifying: true,
|
|
158
|
+
label: eop.label ?? "relates to",
|
|
159
|
+
added: true
|
|
160
|
+
});
|
|
161
|
+
return next;
|
|
162
|
+
}
|
|
163
|
+
case "setRelationshipLabel": {
|
|
164
|
+
const r = findRel(eop.id);
|
|
165
|
+
r.label = eop.label;
|
|
166
|
+
r.dirty = true;
|
|
167
|
+
return next;
|
|
168
|
+
}
|
|
169
|
+
case "setRelationshipCardinality": {
|
|
170
|
+
const r = findRel(eop.id);
|
|
171
|
+
if (eop.leftCard !== void 0) r.leftCard = eop.leftCard;
|
|
172
|
+
if (eop.rightCard !== void 0) r.rightCard = eop.rightCard;
|
|
173
|
+
if (eop.identifying !== void 0) r.identifying = eop.identifying;
|
|
174
|
+
r.dirty = true;
|
|
175
|
+
return next;
|
|
176
|
+
}
|
|
177
|
+
case "reverseRelationship": {
|
|
178
|
+
const r = findRel(eop.id);
|
|
179
|
+
const newLeft = mirrorCard(r.rightCard);
|
|
180
|
+
const newRight = mirrorCard(r.leftCard);
|
|
181
|
+
[r.left, r.right] = [r.right, r.left];
|
|
182
|
+
r.leftCard = newLeft;
|
|
183
|
+
r.rightCard = newRight;
|
|
184
|
+
r.dirty = true;
|
|
185
|
+
return next;
|
|
186
|
+
}
|
|
187
|
+
case "deleteRelationship": {
|
|
188
|
+
findRel(eop.id);
|
|
189
|
+
next.relationships = next.relationships.filter((r) => r.id !== eop.id);
|
|
190
|
+
return next;
|
|
191
|
+
}
|
|
192
|
+
default:
|
|
193
|
+
throw new MermaidOpError("Unsupported operation for ER diagrams");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const erAdapter = {
|
|
197
|
+
diagramType: "er",
|
|
198
|
+
parse,
|
|
199
|
+
serialize,
|
|
200
|
+
applyOp,
|
|
201
|
+
vocabulary: { node: "Entity", addNode: "Add entity", edge: "Relationship" }
|
|
202
|
+
};
|
|
203
|
+
export {
|
|
204
|
+
erAdapter
|
|
205
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowchart adapter — tolerant line-based parse / lossless serialize / ops.
|
|
3
|
+
*
|
|
4
|
+
* Fidelity strategy: every body line is kept in order (SourceLine). Lines
|
|
5
|
+
* bound to entities re-emit verbatim unless the entity is dirty (regenerate,
|
|
6
|
+
* preserving indentation) or deleted (skip). Unrecognized lines that could
|
|
7
|
+
* plausibly be structural force `code-only` — never guess.
|
|
8
|
+
*/
|
|
9
|
+
import type { MermaidAdapter } from "../model/adapter.js";
|
|
10
|
+
import type { FlowchartDoc } from "../model/types.js";
|
|
11
|
+
/** Adapter-owned color palette — emitted as classDef mmdp_<key> lines. */
|
|
12
|
+
export declare const FLOW_PALETTE: Record<string, {
|
|
13
|
+
classDef: string;
|
|
14
|
+
swatch: string;
|
|
15
|
+
label: string;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const flowchartAdapter: MermaidAdapter<FlowchartDoc>;
|