diff --git a/client/src/components/Artifacts/ArtifactPreview.tsx b/client/src/components/Artifacts/ArtifactPreview.tsx index 5c9920c13..d5114ceaf 100644 --- a/client/src/components/Artifacts/ArtifactPreview.tsx +++ b/client/src/components/Artifacts/ArtifactPreview.tsx @@ -4,7 +4,7 @@ import { SandpackProvider, SandpackProviderProps, } from '@codesandbox/sandpack-react/unstyled'; -import type { SandpackPreviewRef } from '@codesandbox/sandpack-react/unstyled'; +import type { SandpackPreviewRef, PreviewProps } from '@codesandbox/sandpack-react/unstyled'; import type { TStartupConfig } from 'librechat-data-provider'; import type { ArtifactFiles } from '~/common'; import { sharedFiles, sharedOptions } from '~/utils/artifacts'; @@ -13,6 +13,7 @@ export const ArtifactPreview = memo(function ({ files, fileKey, template, + isMermaid, sharedProps, previewRef, currentCode, @@ -20,6 +21,7 @@ export const ArtifactPreview = memo(function ({ }: { files: ArtifactFiles; fileKey: string; + isMermaid: boolean; template: SandpackProviderProps['template']; sharedProps: Partial; previewRef: React.MutableRefObject; @@ -54,6 +56,15 @@ export const ArtifactPreview = memo(function ({ return _options; }, [startupConfig, template]); + const style: PreviewProps['style'] | undefined = useMemo(() => { + if (isMermaid) { + return { + backgroundColor: '#282C34', + }; + } + return; + }, [isMermaid]); + if (Object.keys(artifactFiles).length === 0) { return null; } @@ -73,6 +84,7 @@ export const ArtifactPreview = memo(function ({ showRefreshButton={false} tabIndex={0} ref={previewRef} + style={style} /> ); diff --git a/client/src/components/Artifacts/ArtifactTabs.tsx b/client/src/components/Artifacts/ArtifactTabs.tsx index a8792410d..cd8c441ad 100644 --- a/client/src/components/Artifacts/ArtifactTabs.tsx +++ b/client/src/components/Artifacts/ArtifactTabs.tsx @@ -8,6 +8,7 @@ import { useAutoScroll } from '~/hooks/Artifacts/useAutoScroll'; import { ArtifactCodeEditor } from './ArtifactCodeEditor'; import { useGetStartupConfig } from '~/data-provider'; import { ArtifactPreview } from './ArtifactPreview'; +import { MermaidMarkdown } from './MermaidMarkdown'; import { cn } from '~/utils'; export default function ArtifactTabs({ @@ -44,23 +45,25 @@ export default function ArtifactTabs({ id="artifacts-code" className={cn('flex-grow overflow-auto')} > - + {isMermaid ? ( + + ) : ( + + )} - + {/* Main Container */}
{/* Header */}
@@ -74,16 +76,17 @@ export default function Artifacts() { {/* Refresh button */} {activeTab === 'preview' && ( )} diff --git a/client/src/components/Artifacts/MermaidMarkdown.tsx b/client/src/components/Artifacts/MermaidMarkdown.tsx new file mode 100644 index 000000000..780b0d74d --- /dev/null +++ b/client/src/components/Artifacts/MermaidMarkdown.tsx @@ -0,0 +1,11 @@ +import { CodeMarkdown } from './Code'; + +export function MermaidMarkdown({ + content, + isSubmitting, +}: { + content: string; + isSubmitting: boolean; +}) { + return ; +}