diff --git a/client/src/components/Artifacts/ArtifactMarkdown.tsx b/client/src/components/Artifacts/ArtifactMarkdown.tsx new file mode 100644 index 000000000..6117b0479 --- /dev/null +++ b/client/src/components/Artifacts/ArtifactMarkdown.tsx @@ -0,0 +1,18 @@ +import { CodeMarkdown } from './Code'; +import type { Artifact } from '~/common'; +import { getFileExtension } from '~/utils/artifacts'; + +export function ArtifactMarkdown({ + artifact, + isSubmitting, +}: { + artifact: Artifact; + isSubmitting?: boolean; +}) { + return ( + + ); +} 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..4d9bff881 100644 --- a/client/src/components/Artifacts/ArtifactTabs.tsx +++ b/client/src/components/Artifacts/ArtifactTabs.tsx @@ -6,6 +6,7 @@ import { useEditorContext, useArtifactsContext } from '~/Providers'; import useArtifactProps from '~/hooks/Artifacts/useArtifactProps'; import { useAutoScroll } from '~/hooks/Artifacts/useAutoScroll'; import { ArtifactCodeEditor } from './ArtifactCodeEditor'; +import { ArtifactMarkdown } from './ArtifactMarkdown'; import { useGetStartupConfig } from '~/data-provider'; import { ArtifactPreview } from './ArtifactPreview'; import { cn } from '~/utils'; @@ -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' && ( )}