Skip to content

Commit

Permalink
feat: use a code block when generating the message for mermaid instea…
Browse files Browse the repository at this point in the history
…d of using the component directly
  • Loading branch information
Belphemur committed Sep 6, 2023
1 parent c39f252 commit 1274385
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/MessageItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export const MessageItem = memo(function MessageItem({message}: MessageItemProp
inline?: boolean
}, "node" | "className" | "inline" | "lang">) {
if (className == "language-mermaid") {
if(message.isGenerating) {
return <Code block {...props} />;
}
return <Mermaid
chart={`${props.children as string}`}
></Mermaid>
Expand Down Expand Up @@ -124,4 +127,4 @@ export const MessageItem = memo(function MessageItem({message}: MessageItemProp
</Flex>
</Card>
);
}, (prevProps, nextProps) => prevProps.message.content == nextProps.message.content);
}, (prevProps, nextProps) => prevProps.message.content == nextProps.message.content && prevProps.message.isGenerating == nextProps.message.isGenerating);

0 comments on commit 1274385

Please sign in to comment.