fix: added renderer in answer bubble

This commit is contained in:
asminkarki012
2025-04-21 20:50:04 +05:45
parent c5a8f3abcd
commit ea0aa64330
3 changed files with 15 additions and 14 deletions

View File

@@ -3,11 +3,7 @@ import mermaid from 'mermaid';
import CopyButton from './CopyButton';
import { useSelector } from 'react-redux';
import { selectStatus } from '../conversation/conversationSlice';
interface MermaidRendererProps {
code: string;
isDarkTheme: boolean;
}
import { MermaidRendererProps } from './types';
const MermaidRenderer: React.FC<MermaidRendererProps> = ({
code,

View File

@@ -22,3 +22,8 @@ export type InputProps = {
e: React.KeyboardEvent<HTMLTextAreaElement | HTMLInputElement>,
) => void;
};
export type MermaidRendererProps = {
code: string;
isDarkTheme: boolean;
};

View File

@@ -403,6 +403,15 @@ const ConversationBubble = forwardRef<
const match = /language-(\w+)/.exec(className || '');
const language = match ? match[1] : '';
if (language === 'mermaid') {
return (
<MermaidRenderer
isDarkTheme={isDarkTheme}
code={String(children)}
/>
);
}
return match ? (
<div className="group relative rounded-[14px] overflow-hidden border border-light-silver dark:border-raisin-black">
<div className="flex justify-between items-center px-2 py-1 bg-platinum dark:bg-eerie-black-2">
@@ -792,15 +801,6 @@ function Thought({
const match = /language-(\w+)/.exec(className || '');
const language = match ? match[1] : '';
if (language === 'mermaid') {
return (
<MermaidRenderer
isDarkTheme={isDarkTheme}
code={String(children)}
/>
);
}
return match ? (
<div className="group relative rounded-[14px] overflow-hidden border border-light-silver dark:border-raisin-black">
<div className="flex justify-between items-center px-2 py-1 bg-platinum dark:bg-eerie-black-2">