@ai-matrx/rich-content 0.2.4 → 0.2.7
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 +25 -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 +48 -10
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button } from "@ai-matrx/design-system/controls";
|
|
4
|
+
import { Suspense, lazy, useEffect, useState } from "react";
|
|
5
|
+
import {
|
|
6
|
+
Check,
|
|
7
|
+
Copy,
|
|
8
|
+
Code2,
|
|
9
|
+
Download,
|
|
10
|
+
Expand,
|
|
11
|
+
FolderUp,
|
|
12
|
+
Maximize2,
|
|
13
|
+
Palette,
|
|
14
|
+
Zap
|
|
15
|
+
} from "lucide-react";
|
|
16
|
+
import { toast } from "../../../host/toast.js";
|
|
17
|
+
import {
|
|
18
|
+
DropdownMenu,
|
|
19
|
+
DropdownMenuContent,
|
|
20
|
+
DropdownMenuItem,
|
|
21
|
+
DropdownMenuLabel,
|
|
22
|
+
DropdownMenuSeparator,
|
|
23
|
+
DropdownMenuTrigger
|
|
24
|
+
} from "@ai-matrx/design-system";
|
|
25
|
+
import MatrxMiniLoader from "../../../utils/lifted/MatrxMiniLoader.js";
|
|
26
|
+
import { SimpleTooltip } from "../../../utils/lifted/Tooltip.js";
|
|
27
|
+
import { useCanvas } from "../../../host/app-bindings.js";
|
|
28
|
+
import { useOpenArtifactInCanvas } from "../../../host/app-bindings.js";
|
|
29
|
+
import { isMaterializedArtifactId } from "../../../utils/lifted/artifactId.js";
|
|
30
|
+
import { useCanvasOpenGuard } from "../../../host/app-bindings.js";
|
|
31
|
+
import { useThemeMode } from "../../../host/app-bindings.js";
|
|
32
|
+
import { useMermaidPreferences, useSetMermaidPreferences, useDiagramAgents, createMermaidEditorScope, hostMermaidEditorManifest } from "../../../host/app-bindings.js";
|
|
33
|
+
import { cn } from "@ai-matrx/design-system";
|
|
34
|
+
import { NonEditableContextMenu } from "../../../host/app-bindings.js";
|
|
35
|
+
import {
|
|
36
|
+
getCatalogEntry,
|
|
37
|
+
getFeaturedCatalogEntries
|
|
38
|
+
} from "../../../mermaid/catalog.js";
|
|
39
|
+
import {
|
|
40
|
+
detectDiagramType,
|
|
41
|
+
extractMermaidTitle
|
|
42
|
+
} from "../../../mermaid/diagram-type.js";
|
|
43
|
+
import {
|
|
44
|
+
copyMermaidSource,
|
|
45
|
+
downloadMermaidPng,
|
|
46
|
+
downloadMermaidSource,
|
|
47
|
+
downloadMermaidSvg,
|
|
48
|
+
saveMermaidToWorkspace
|
|
49
|
+
} from "../../../mermaid/export.js";
|
|
50
|
+
import { MermaidRenderer } from "../../../mermaid/MermaidRenderer.js";
|
|
51
|
+
import { MermaidFullscreen } from "../../../mermaid/MermaidFullscreen.js";
|
|
52
|
+
import { preloadMermaid } from "../../../mermaid/runtime.js";
|
|
53
|
+
import {
|
|
54
|
+
resolveMermaidTheme,
|
|
55
|
+
DEFAULT_MERMAID_PREFERENCES
|
|
56
|
+
} from "../../../mermaid/types.js";
|
|
57
|
+
const CodeBlock = lazy(
|
|
58
|
+
() => import("../../../code-block/CodeBlock.js")
|
|
59
|
+
);
|
|
60
|
+
const THEME_CHOICES = [
|
|
61
|
+
"auto",
|
|
62
|
+
"default",
|
|
63
|
+
"dark",
|
|
64
|
+
"forest",
|
|
65
|
+
"neutral",
|
|
66
|
+
"base"
|
|
67
|
+
];
|
|
68
|
+
const LOOK_CHOICES = ["classic", "handDrawn"];
|
|
69
|
+
const LAYOUT_CHOICES = ["dagre", "elk"];
|
|
70
|
+
const MermaidBlock = ({
|
|
71
|
+
content,
|
|
72
|
+
serverData,
|
|
73
|
+
metadata,
|
|
74
|
+
isStreamActive = false,
|
|
75
|
+
conversationId,
|
|
76
|
+
messageId,
|
|
77
|
+
taskId,
|
|
78
|
+
className,
|
|
79
|
+
artifactId,
|
|
80
|
+
artifactVersion
|
|
81
|
+
}) => {
|
|
82
|
+
const setMermaidPreferences = useSetMermaidPreferences();
|
|
83
|
+
const { open } = useCanvas();
|
|
84
|
+
const { openArtifact } = useOpenArtifactInCanvas();
|
|
85
|
+
const { isCanvasAvailable } = useCanvasOpenGuard();
|
|
86
|
+
const appMode = useThemeMode();
|
|
87
|
+
const userPrefs = { ...DEFAULT_MERMAID_PREFERENCES, ...useMermaidPreferences() };
|
|
88
|
+
const source = serverData?.source ?? content ?? "";
|
|
89
|
+
const artifactMeta = metadata?.mermaid ?? metadata ?? {};
|
|
90
|
+
const [localOptions, setLocalOptions] = useState({});
|
|
91
|
+
const effective = {
|
|
92
|
+
theme: localOptions.theme ?? artifactMeta.theme ?? userPrefs.theme,
|
|
93
|
+
look: localOptions.look ?? artifactMeta.look ?? userPrefs.look,
|
|
94
|
+
layout: localOptions.layout ?? artifactMeta.layout ?? userPrefs.layout
|
|
95
|
+
};
|
|
96
|
+
const renderOptions = {
|
|
97
|
+
theme: resolveMermaidTheme(effective.theme, appMode),
|
|
98
|
+
look: effective.look,
|
|
99
|
+
layout: effective.layout
|
|
100
|
+
};
|
|
101
|
+
const [showSource, setShowSource] = useState(false);
|
|
102
|
+
const [copied, setCopied] = useState(false);
|
|
103
|
+
const [fullscreen, setFullscreen] = useState(false);
|
|
104
|
+
const [svgEl, setSvgEl] = useState(null);
|
|
105
|
+
const [frameMaxHeight, setFrameMaxHeight] = useState(520);
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
const recompute = () => setFrameMaxHeight(
|
|
108
|
+
Math.max(320, Math.min(720, Math.round(window.innerHeight * 0.6)))
|
|
109
|
+
);
|
|
110
|
+
recompute();
|
|
111
|
+
window.addEventListener("resize", recompute);
|
|
112
|
+
return () => window.removeEventListener("resize", recompute);
|
|
113
|
+
}, []);
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
preloadMermaid();
|
|
116
|
+
}, []);
|
|
117
|
+
const diagramType = detectDiagramType(source);
|
|
118
|
+
const catalog = getCatalogEntry(diagramType);
|
|
119
|
+
const title = serverData?.title ?? extractMermaidTitle(source) ?? artifactMeta.title ?? null;
|
|
120
|
+
const Icon = catalog.icon;
|
|
121
|
+
const currentSvg = () => svgEl?.outerHTML ?? null;
|
|
122
|
+
const handleCopy = async () => {
|
|
123
|
+
await copyMermaidSource(source);
|
|
124
|
+
setCopied(true);
|
|
125
|
+
setTimeout(() => setCopied(false), 1500);
|
|
126
|
+
};
|
|
127
|
+
const handleSaveToWorkspace = async () => {
|
|
128
|
+
const svg = currentSvg();
|
|
129
|
+
if (!svg) {
|
|
130
|
+
toast.error("Nothing rendered to save yet");
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
await saveMermaidToWorkspace({ svg, source, title });
|
|
135
|
+
toast.success("Saved to your files (Diagrams folder)");
|
|
136
|
+
} catch (err) {
|
|
137
|
+
console.error("[MermaidBlock] save to workspace failed", err);
|
|
138
|
+
toast.error("Could not save the diagram to your files");
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const handleOpenCanvas = (aiAgent) => {
|
|
142
|
+
const extras = {
|
|
143
|
+
// Chat right-click -> "Edit with <agent>": land in the workbench with
|
|
144
|
+
// the AI rail open + the diagram-scoped agent preselected, so the
|
|
145
|
+
// agent's result flows through the workbench's normal apply/version
|
|
146
|
+
// pipeline (APPLY_EXTERNAL_SOURCE -> saved as a new version).
|
|
147
|
+
...aiAgent ? {
|
|
148
|
+
openAiRail: true,
|
|
149
|
+
aiAgentId: aiAgent.agentId,
|
|
150
|
+
aiAgentName: aiAgent.name
|
|
151
|
+
} : {},
|
|
152
|
+
mermaid: {
|
|
153
|
+
diagramType,
|
|
154
|
+
title: title ?? void 0,
|
|
155
|
+
theme: effective.theme,
|
|
156
|
+
look: effective.look,
|
|
157
|
+
layout: effective.layout
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
if (isMaterializedArtifactId(artifactId)) {
|
|
161
|
+
void openArtifact({
|
|
162
|
+
canvasType: "mermaid",
|
|
163
|
+
title: title ?? catalog.label,
|
|
164
|
+
content: source,
|
|
165
|
+
artifactId,
|
|
166
|
+
messageId,
|
|
167
|
+
conversationId,
|
|
168
|
+
metadata: extras
|
|
169
|
+
});
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
open({
|
|
173
|
+
type: "mermaid",
|
|
174
|
+
data: source,
|
|
175
|
+
metadata: {
|
|
176
|
+
title: title ?? catalog.label,
|
|
177
|
+
sourceMessageId: messageId,
|
|
178
|
+
sourceTaskId: taskId || (messageId ? `mermaid:${messageId}` : void 0),
|
|
179
|
+
canvasItemId: artifactId,
|
|
180
|
+
conversationId,
|
|
181
|
+
...extras
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
const setOption = (key, value) => setLocalOptions((prev) => ({ ...prev, [key]: value }));
|
|
186
|
+
const diagramAgents = useDiagramAgents();
|
|
187
|
+
const getApplicationScope = () => createMermaidEditorScope({
|
|
188
|
+
content: source,
|
|
189
|
+
diagram_source: source,
|
|
190
|
+
diagram_type: diagramType,
|
|
191
|
+
diagram_title: title ?? void 0,
|
|
192
|
+
editor_mode: "chat-block",
|
|
193
|
+
validation_state: "unknown",
|
|
194
|
+
available_diagram_types: getFeaturedCatalogEntries().map((e) => e.type),
|
|
195
|
+
canvas_item_id: artifactId,
|
|
196
|
+
version: artifactVersion,
|
|
197
|
+
conversation_id: conversationId
|
|
198
|
+
});
|
|
199
|
+
const diagramSections = !isStreamActive && isCanvasAvailable && diagramAgents.length > 0 ? [
|
|
200
|
+
{
|
|
201
|
+
id: "diagram-agents",
|
|
202
|
+
label: "Diagram",
|
|
203
|
+
items: diagramAgents.map((agent) => ({
|
|
204
|
+
kind: "item",
|
|
205
|
+
id: `diagram-agent-${agent.agentId}`,
|
|
206
|
+
label: `Edit with ${agent.name}`,
|
|
207
|
+
icon: Zap,
|
|
208
|
+
onSelect: () => handleOpenCanvas(agent)
|
|
209
|
+
}))
|
|
210
|
+
}
|
|
211
|
+
] : [];
|
|
212
|
+
return /* @__PURE__ */ jsx(
|
|
213
|
+
NonEditableContextMenu,
|
|
214
|
+
{
|
|
215
|
+
sourceFeature: "chat",
|
|
216
|
+
surfaceName: hostMermaidEditorManifest()?.surfaceName ?? "mermaid-editor",
|
|
217
|
+
getApplicationScope,
|
|
218
|
+
contentSource: artifactId ? { type: "artifact", artifactId } : void 0,
|
|
219
|
+
extraSections: diagramSections,
|
|
220
|
+
children: /* @__PURE__ */ jsxs(
|
|
221
|
+
"div",
|
|
222
|
+
{
|
|
223
|
+
className: cn(
|
|
224
|
+
"my-3 overflow-hidden rounded-lg border border-border bg-card",
|
|
225
|
+
className
|
|
226
|
+
),
|
|
227
|
+
children: [
|
|
228
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 border-b border-border bg-muted/50 px-3 py-1.5", children: [
|
|
229
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
230
|
+
/* @__PURE__ */ jsx(Icon, { className: "h-3.5 w-3.5 shrink-0 text-primary" }),
|
|
231
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-foreground", children: title ?? catalog.label }),
|
|
232
|
+
title && /* @__PURE__ */ jsx("span", { className: "hidden shrink-0 text-xs text-muted-foreground sm:inline", children: catalog.label }),
|
|
233
|
+
artifactVersion && artifactVersion > 1 ? /* @__PURE__ */ jsxs("span", { className: "shrink-0 rounded border border-border bg-muted px-1 py-px text-[10px] text-muted-foreground", children: [
|
|
234
|
+
"v",
|
|
235
|
+
artifactVersion
|
|
236
|
+
] }) : null,
|
|
237
|
+
isStreamActive && /* @__PURE__ */ jsx("span", { className: "shrink-0 animate-pulse text-xs text-muted-foreground", children: "drawing\u2026" })
|
|
238
|
+
] }),
|
|
239
|
+
!isStreamActive && /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-0.5", children: [
|
|
240
|
+
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
241
|
+
/* @__PURE__ */ jsx(SimpleTooltip, { text: "Diagram style", children: /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "quiet", icon: /* @__PURE__ */ jsx(Palette, {}), "aria-label": "Diagram style" }) }) }),
|
|
242
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-44", children: [
|
|
243
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { className: "text-xs", children: "Theme" }),
|
|
244
|
+
THEME_CHOICES.map((theme) => /* @__PURE__ */ jsxs(
|
|
245
|
+
DropdownMenuItem,
|
|
246
|
+
{
|
|
247
|
+
onClick: () => setOption("theme", theme),
|
|
248
|
+
children: [
|
|
249
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1 capitalize", children: theme }),
|
|
250
|
+
effective.theme === theme && /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5" })
|
|
251
|
+
]
|
|
252
|
+
},
|
|
253
|
+
theme
|
|
254
|
+
)),
|
|
255
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
256
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { className: "text-xs", children: "Style" }),
|
|
257
|
+
LOOK_CHOICES.map((look) => /* @__PURE__ */ jsxs(
|
|
258
|
+
DropdownMenuItem,
|
|
259
|
+
{
|
|
260
|
+
onClick: () => setOption("look", look),
|
|
261
|
+
children: [
|
|
262
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1", children: look === "handDrawn" ? "Hand-drawn" : "Classic" }),
|
|
263
|
+
effective.look === look && /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5" })
|
|
264
|
+
]
|
|
265
|
+
},
|
|
266
|
+
look
|
|
267
|
+
)),
|
|
268
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
269
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { className: "text-xs", children: "Layout" }),
|
|
270
|
+
LAYOUT_CHOICES.map((layout) => /* @__PURE__ */ jsxs(
|
|
271
|
+
DropdownMenuItem,
|
|
272
|
+
{
|
|
273
|
+
onClick: () => setOption("layout", layout),
|
|
274
|
+
children: [
|
|
275
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1 uppercase", children: layout }),
|
|
276
|
+
effective.layout === layout && /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5" })
|
|
277
|
+
]
|
|
278
|
+
},
|
|
279
|
+
layout
|
|
280
|
+
)),
|
|
281
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
282
|
+
/* @__PURE__ */ jsx(
|
|
283
|
+
DropdownMenuItem,
|
|
284
|
+
{
|
|
285
|
+
onClick: () => {
|
|
286
|
+
setMermaidPreferences(effective);
|
|
287
|
+
toast.success("Saved as your default diagram style");
|
|
288
|
+
},
|
|
289
|
+
children: "Save as my default"
|
|
290
|
+
}
|
|
291
|
+
)
|
|
292
|
+
] })
|
|
293
|
+
] }),
|
|
294
|
+
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
295
|
+
/* @__PURE__ */ jsx(SimpleTooltip, { text: "Export diagram", children: /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "quiet", icon: /* @__PURE__ */ jsx(Download, {}), "aria-label": "Export diagram" }) }) }),
|
|
296
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-48", children: [
|
|
297
|
+
/* @__PURE__ */ jsx(
|
|
298
|
+
DropdownMenuItem,
|
|
299
|
+
{
|
|
300
|
+
onClick: () => {
|
|
301
|
+
const svg = currentSvg();
|
|
302
|
+
if (svg) downloadMermaidSvg(svg, title);
|
|
303
|
+
else toast.error("Nothing rendered yet");
|
|
304
|
+
},
|
|
305
|
+
children: "Download SVG"
|
|
306
|
+
}
|
|
307
|
+
),
|
|
308
|
+
/* @__PURE__ */ jsx(
|
|
309
|
+
DropdownMenuItem,
|
|
310
|
+
{
|
|
311
|
+
onClick: async () => {
|
|
312
|
+
const svg = currentSvg();
|
|
313
|
+
if (!svg) {
|
|
314
|
+
toast.error("Nothing rendered yet");
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
try {
|
|
318
|
+
await downloadMermaidPng(svg, title);
|
|
319
|
+
} catch (err) {
|
|
320
|
+
console.error("[MermaidBlock] PNG export failed", err);
|
|
321
|
+
toast.error("PNG export failed");
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
children: "Download PNG"
|
|
325
|
+
}
|
|
326
|
+
),
|
|
327
|
+
/* @__PURE__ */ jsx(
|
|
328
|
+
DropdownMenuItem,
|
|
329
|
+
{
|
|
330
|
+
onClick: () => downloadMermaidSource(source, title),
|
|
331
|
+
children: "Download source (.mmd)"
|
|
332
|
+
}
|
|
333
|
+
),
|
|
334
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
335
|
+
/* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: handleSaveToWorkspace, children: [
|
|
336
|
+
/* @__PURE__ */ jsx(FolderUp, { className: "mr-1.5 h-3.5 w-3.5" }),
|
|
337
|
+
"Save to my files"
|
|
338
|
+
] })
|
|
339
|
+
] })
|
|
340
|
+
] }),
|
|
341
|
+
/* @__PURE__ */ jsx(SimpleTooltip, { text: copied ? "Copied" : "Copy diagram source", children: /* @__PURE__ */ jsx(Button, { variant: "quiet", icon: copied ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Copy, {}), "aria-label": "Copy diagram source", onClick: handleCopy }) }),
|
|
342
|
+
/* @__PURE__ */ jsx(SimpleTooltip, { text: showSource ? "Hide source" : "Show source", children: /* @__PURE__ */ jsx(Button, { variant: "quiet", pressed: showSource, icon: /* @__PURE__ */ jsx(Code2, {}), "aria-label": showSource ? "Hide source" : "Show source", onClick: () => setShowSource((v) => !v) }) }),
|
|
343
|
+
/* @__PURE__ */ jsx(SimpleTooltip, { text: "View fullscreen", children: /* @__PURE__ */ jsx(Button, { variant: "quiet", icon: /* @__PURE__ */ jsx(Expand, {}), "aria-label": "View fullscreen", onClick: () => setFullscreen(true) }) }),
|
|
344
|
+
isCanvasAvailable && /* @__PURE__ */ jsx(SimpleTooltip, { text: "Open in canvas", children: /* @__PURE__ */ jsx(
|
|
345
|
+
Button,
|
|
346
|
+
{
|
|
347
|
+
type: "button",
|
|
348
|
+
"aria-label": "Open in canvas",
|
|
349
|
+
onClick: () => handleOpenCanvas(),
|
|
350
|
+
variant: "quiet",
|
|
351
|
+
icon: /* @__PURE__ */ jsx(Maximize2, {}),
|
|
352
|
+
children: "Canvas"
|
|
353
|
+
}
|
|
354
|
+
) })
|
|
355
|
+
] })
|
|
356
|
+
] }),
|
|
357
|
+
/* @__PURE__ */ jsx(
|
|
358
|
+
MermaidRenderer,
|
|
359
|
+
{
|
|
360
|
+
source,
|
|
361
|
+
options: renderOptions,
|
|
362
|
+
isStreamActive,
|
|
363
|
+
onSvgMounted: setSvgEl,
|
|
364
|
+
viewportMaxHeight: frameMaxHeight
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
showSource && !isStreamActive && /* @__PURE__ */ jsx("div", { className: "border-t border-border", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(MatrxMiniLoader, {}), children: /* @__PURE__ */ jsx(CodeBlock, { showSource: true, code: source, language: "mermaid", fontSize: 13 }) }) }),
|
|
368
|
+
fullscreen && /* @__PURE__ */ jsx(
|
|
369
|
+
MermaidFullscreen,
|
|
370
|
+
{
|
|
371
|
+
source,
|
|
372
|
+
options: renderOptions,
|
|
373
|
+
title: title ?? catalog.label,
|
|
374
|
+
onClose: () => setFullscreen(false)
|
|
375
|
+
}
|
|
376
|
+
)
|
|
377
|
+
]
|
|
378
|
+
}
|
|
379
|
+
)
|
|
380
|
+
}
|
|
381
|
+
);
|
|
382
|
+
};
|
|
383
|
+
var MermaidBlock_default = MermaidBlock;
|
|
384
|
+
export {
|
|
385
|
+
MermaidBlock_default as default
|
|
386
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SearchReplaceBlock — Content Block for SEARCH/REPLACE instructions
|
|
3
|
+
*
|
|
4
|
+
* Rendered when the server sends a `content_block` event with type "search_replace".
|
|
5
|
+
*
|
|
6
|
+
* Supports two render modes:
|
|
7
|
+
* 1. Server-processed: `serverData` carries pre-parsed { search, replace, … }
|
|
8
|
+
* 2. Streaming/fallback: raw `content` string is delegated to StreamingDiffBlock
|
|
9
|
+
*
|
|
10
|
+
* When `isStreamActive` is true:
|
|
11
|
+
* - Phase 1 (search buffering): shows "Analyzing code…" loader
|
|
12
|
+
* - Phase 2 (replace streaming): shows replacement code with GENERATING badge
|
|
13
|
+
* - Phase 3 (both complete): collapses into a diff view
|
|
14
|
+
* When `isStreamActive` is false (history / stored message):
|
|
15
|
+
* - Renders final collapsed diff view immediately
|
|
16
|
+
*/
|
|
17
|
+
import React from "react";
|
|
18
|
+
export interface SearchReplaceBlockData {
|
|
19
|
+
/** The code / text to find (exact). */
|
|
20
|
+
search: string;
|
|
21
|
+
/** The replacement code / text. */
|
|
22
|
+
replace: string;
|
|
23
|
+
/** True once the SEARCH section has finished streaming. */
|
|
24
|
+
searchComplete: boolean;
|
|
25
|
+
/** True once the REPLACE section has finished streaming. */
|
|
26
|
+
replaceComplete: boolean;
|
|
27
|
+
/** True when both sections are complete. */
|
|
28
|
+
isComplete: boolean;
|
|
29
|
+
/** Source language for syntax highlighting (e.g. "typescript"). */
|
|
30
|
+
language?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface SearchReplaceBlockProps {
|
|
33
|
+
/**
|
|
34
|
+
* Pre-parsed structured data from the server.
|
|
35
|
+
* When present, the component renders from this directly.
|
|
36
|
+
*/
|
|
37
|
+
serverData?: SearchReplaceBlockData | Record<string, unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* Raw streaming content string (fallback when serverData is absent).
|
|
40
|
+
* Must be the full text content of a SEARCH/REPLACE block including delimiters.
|
|
41
|
+
*/
|
|
42
|
+
content?: string;
|
|
43
|
+
/** Whether the block is still actively streaming. */
|
|
44
|
+
isStreamActive?: boolean;
|
|
45
|
+
/** Source language for syntax highlighting. Defaults to "typescript". */
|
|
46
|
+
language?: string;
|
|
47
|
+
className?: string;
|
|
48
|
+
}
|
|
49
|
+
export declare const SearchReplaceBlock: React.FC<SearchReplaceBlockProps>;
|
|
50
|
+
export default SearchReplaceBlock;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { SearchReplaceDiffRenderer } from "../../chat-markdown/diff-blocks/renderers/SearchReplaceDiffRenderer.js";
|
|
4
|
+
import { StreamingDiffBlock } from "../../chat-markdown/diff-blocks/StreamingDiffBlock.js";
|
|
5
|
+
import { DiffLoadingIndicator } from "../../chat-markdown/diff-blocks/DiffLoadingIndicator.js";
|
|
6
|
+
import { cn } from "@ai-matrx/design-system";
|
|
7
|
+
const SearchReplaceBlock = ({
|
|
8
|
+
serverData,
|
|
9
|
+
content,
|
|
10
|
+
isStreamActive = false,
|
|
11
|
+
language = "typescript",
|
|
12
|
+
className
|
|
13
|
+
}) => {
|
|
14
|
+
if (serverData && typeof serverData === "object" && "search" in serverData) {
|
|
15
|
+
const data = serverData;
|
|
16
|
+
const effectiveLanguage = data.language ?? language;
|
|
17
|
+
if (!data.search && !data.replace) {
|
|
18
|
+
return /* @__PURE__ */ jsx(
|
|
19
|
+
"div",
|
|
20
|
+
{
|
|
21
|
+
className: cn(
|
|
22
|
+
"rounded-lg border border-neutral-200 dark:border-neutral-700 bg-muted/30",
|
|
23
|
+
className
|
|
24
|
+
),
|
|
25
|
+
children: /* @__PURE__ */ jsx(DiffLoadingIndicator, { message: "Preparing code changes\u2026" })
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
SearchReplaceDiffRenderer,
|
|
31
|
+
{
|
|
32
|
+
data: {
|
|
33
|
+
search: data.search ?? "",
|
|
34
|
+
replace: data.replace ?? "",
|
|
35
|
+
searchComplete: data.searchComplete ?? !isStreamActive,
|
|
36
|
+
replaceComplete: data.replaceComplete ?? !isStreamActive,
|
|
37
|
+
isComplete: data.isComplete ?? !isStreamActive
|
|
38
|
+
},
|
|
39
|
+
language: effectiveLanguage,
|
|
40
|
+
isStreamActive,
|
|
41
|
+
className
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
if (content) {
|
|
46
|
+
return /* @__PURE__ */ jsx(
|
|
47
|
+
StreamingDiffBlock,
|
|
48
|
+
{
|
|
49
|
+
content,
|
|
50
|
+
language,
|
|
51
|
+
isStreamActive,
|
|
52
|
+
className
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return /* @__PURE__ */ jsx(
|
|
57
|
+
"div",
|
|
58
|
+
{
|
|
59
|
+
className: cn(
|
|
60
|
+
"rounded-lg border border-neutral-200 dark:border-neutral-700 bg-muted/30",
|
|
61
|
+
className
|
|
62
|
+
),
|
|
63
|
+
children: /* @__PURE__ */ jsx(DiffLoadingIndicator, { message: "Waiting for changes\u2026" })
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
var SearchReplaceBlock_default = SearchReplaceBlock;
|
|
68
|
+
export {
|
|
69
|
+
SearchReplaceBlock,
|
|
70
|
+
SearchReplaceBlock_default as default
|
|
71
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useClipboard } from "@ai-matrx/kit/clipboard";
|
|
4
|
+
import { useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { createPortal } from "react-dom";
|
|
6
|
+
import { Check, Copy, Download, Expand, Image as ImageIcon, X } from "lucide-react";
|
|
7
|
+
import { toast } from "../../../host/toast.js";
|
|
8
|
+
import { Skeleton } from "@ai-matrx/design-system";
|
|
9
|
+
import SandboxedHtml from "../common/SandboxedHtml.js";
|
|
10
|
+
import { cn } from "@ai-matrx/design-system";
|
|
11
|
+
import { Button } from "@ai-matrx/design-system/controls";
|
|
12
|
+
function readSvgMeta(svg) {
|
|
13
|
+
let aspect = 16 / 9;
|
|
14
|
+
const viewBox = /viewBox\s*=\s*["']\s*[\d.+-]+\s+[\d.+-]+\s+([\d.]+)\s+([\d.]+)\s*["']/i.exec(svg);
|
|
15
|
+
if (viewBox) {
|
|
16
|
+
const w = parseFloat(viewBox[1]);
|
|
17
|
+
const h = parseFloat(viewBox[2]);
|
|
18
|
+
if (w > 0 && h > 0) aspect = w / h;
|
|
19
|
+
} else {
|
|
20
|
+
const w = /\bwidth\s*=\s*["']?([\d.]+)/i.exec(svg);
|
|
21
|
+
const h = /\bheight\s*=\s*["']?([\d.]+)/i.exec(svg);
|
|
22
|
+
if (w && h && +w[1] > 0 && +h[1] > 0) aspect = +w[1] / +h[1];
|
|
23
|
+
}
|
|
24
|
+
const titleEl = /<title[^>]*>([\s\S]*?)<\/title>/i.exec(svg);
|
|
25
|
+
const ariaLabel = /<svg[^>]*\saria-label\s*=\s*["']([^"']+)["']/i.exec(svg);
|
|
26
|
+
const title = (titleEl?.[1] ?? ariaLabel?.[1] ?? "").trim() || null;
|
|
27
|
+
return { aspect, title };
|
|
28
|
+
}
|
|
29
|
+
function toSrcDoc(svg) {
|
|
30
|
+
return `<!DOCTYPE html><html><head><meta charset="utf-8"><style>html,body{margin:0;padding:0;height:100%;background:transparent;overflow:hidden}svg{display:block;width:100%;height:100%}</style></head><body>${svg}</body></html>`;
|
|
31
|
+
}
|
|
32
|
+
const SvgBlock = ({ content = "", isStreamActive = false, className }) => {
|
|
33
|
+
const { copyText } = useClipboard({
|
|
34
|
+
notify: (message, kind) => kind === "error" ? toast.error(message) : toast.success(message)
|
|
35
|
+
});
|
|
36
|
+
const svg = content.trim();
|
|
37
|
+
const { aspect, title } = useMemo(() => readSvgMeta(svg), [svg]);
|
|
38
|
+
const srcDoc = useMemo(() => toSrcDoc(svg), [svg]);
|
|
39
|
+
const [copied, setCopied] = useState(false);
|
|
40
|
+
const [fullscreen, setFullscreen] = useState(false);
|
|
41
|
+
const handleCopy = async () => {
|
|
42
|
+
try {
|
|
43
|
+
await copyText(svg);
|
|
44
|
+
setCopied(true);
|
|
45
|
+
setTimeout(() => setCopied(false), 1500);
|
|
46
|
+
} catch {
|
|
47
|
+
toast.error("Couldn't copy the SVG");
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const handleDownload = () => {
|
|
51
|
+
try {
|
|
52
|
+
const blob = new Blob([svg], { type: "image/svg+xml" });
|
|
53
|
+
const url = URL.createObjectURL(blob);
|
|
54
|
+
const a = document.createElement("a");
|
|
55
|
+
a.href = url;
|
|
56
|
+
a.download = `${(title ?? "illustration").replace(/[^\w-]+/g, "-").toLowerCase()}.svg`;
|
|
57
|
+
a.click();
|
|
58
|
+
URL.revokeObjectURL(url);
|
|
59
|
+
} catch {
|
|
60
|
+
toast.error("Couldn't download the SVG");
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const hasSvg = /<svg[\s>]/i.test(svg);
|
|
64
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("my-3 overflow-hidden rounded-lg border border-border bg-card", className), children: [
|
|
65
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 border-b border-border bg-muted/50 px-3 py-1.5", children: [
|
|
66
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
67
|
+
/* @__PURE__ */ jsx(ImageIcon, { className: "h-3.5 w-3.5 shrink-0 text-primary" }),
|
|
68
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-foreground", children: title ?? "Illustration" }),
|
|
69
|
+
/* @__PURE__ */ jsx("span", { className: "hidden shrink-0 text-xs text-muted-foreground sm:inline", children: "SVG" }),
|
|
70
|
+
isStreamActive && /* @__PURE__ */ jsx("span", { className: "shrink-0 animate-pulse text-xs text-muted-foreground", children: "drawing\u2026" })
|
|
71
|
+
] }),
|
|
72
|
+
!isStreamActive && hasSvg && /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-0.5", children: [
|
|
73
|
+
/* @__PURE__ */ jsx(IconBtn, { label: copied ? "Copied" : "Copy SVG source", onClick: handleCopy, children: copied ? /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsx(Copy, { className: "h-3.5 w-3.5" }) }),
|
|
74
|
+
/* @__PURE__ */ jsx(IconBtn, { label: "Download SVG", onClick: handleDownload, children: /* @__PURE__ */ jsx(Download, { className: "h-3.5 w-3.5" }) }),
|
|
75
|
+
/* @__PURE__ */ jsx(IconBtn, { label: "View fullscreen", onClick: () => setFullscreen(true), children: /* @__PURE__ */ jsx(Expand, { className: "h-3.5 w-3.5" }) })
|
|
76
|
+
] })
|
|
77
|
+
] }),
|
|
78
|
+
/* @__PURE__ */ jsx("div", { className: "p-3", children: isStreamActive || !hasSvg ? /* @__PURE__ */ jsxs("div", { className: "space-y-2", "aria-busy": "true", children: [
|
|
79
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/3" }),
|
|
80
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-40 w-full" })
|
|
81
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "mx-auto w-full", style: { aspectRatio: `${aspect}`, maxHeight: "70dvh" }, children: /* @__PURE__ */ jsx(SandboxedHtml, { html: srcDoc, title: title ?? "SVG illustration", height: "100%", className: "rounded-md" }) }) }),
|
|
82
|
+
fullscreen && /* @__PURE__ */ jsx(SvgFullscreen, { srcDoc, title, onClose: () => setFullscreen(false) })
|
|
83
|
+
] });
|
|
84
|
+
};
|
|
85
|
+
function IconBtn({ label, onClick, children }) {
|
|
86
|
+
return /* @__PURE__ */ jsx(Button, { variant: "quiet", "aria-label": label, title: label, onClick, children });
|
|
87
|
+
}
|
|
88
|
+
function SvgFullscreen({ srcDoc, title, onClose }) {
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
const onKey = (e) => {
|
|
91
|
+
if (e.key === "Escape") onClose();
|
|
92
|
+
};
|
|
93
|
+
window.addEventListener("keydown", onKey);
|
|
94
|
+
const prev = document.body.style.overflow;
|
|
95
|
+
document.body.style.overflow = "hidden";
|
|
96
|
+
return () => {
|
|
97
|
+
window.removeEventListener("keydown", onKey);
|
|
98
|
+
document.body.style.overflow = prev;
|
|
99
|
+
};
|
|
100
|
+
}, [onClose]);
|
|
101
|
+
if (typeof document === "undefined") return null;
|
|
102
|
+
return createPortal(
|
|
103
|
+
/* @__PURE__ */ jsxs(
|
|
104
|
+
"div",
|
|
105
|
+
{
|
|
106
|
+
className: "fixed inset-0 z-[120] flex flex-col bg-background/98 backdrop-blur-sm",
|
|
107
|
+
role: "dialog",
|
|
108
|
+
"aria-modal": "true",
|
|
109
|
+
"aria-label": title ?? "Illustration (fullscreen)",
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b border-border px-4 py-2 pt-safe", children: [
|
|
112
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-foreground", children: title ?? "Illustration" }),
|
|
113
|
+
/* @__PURE__ */ jsx(Button, { variant: "quiet", icon: /* @__PURE__ */ jsx(X, {}), "aria-label": "Exit fullscreen", title: "Exit fullscreen (Esc)", onClick: onClose })
|
|
114
|
+
] }),
|
|
115
|
+
/* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 p-4", onClick: (e) => e.target === e.currentTarget && onClose(), children: /* @__PURE__ */ jsx(SandboxedHtml, { html: srcDoc, title: title ?? "SVG illustration", height: "100%" }) })
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
document.body
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
var SvgBlock_default = SvgBlock;
|
|
123
|
+
export {
|
|
124
|
+
SvgBlock,
|
|
125
|
+
SvgBlock_default as default
|
|
126
|
+
};
|