
MessageMarkdown: - Removed unused imports. - Modified useEffect() to analyze steps using mdast-util-from-markdown instead of splitting children directly. - Modified code component to set the 'index' property based on the order of 'code' nodes in the tree. MessageBody: - Removed the messageText prop and replaced it with children prop to allow more flexibility in passing content. - Updated the usage of MessageMarkdown to pass the temp prop as needed. CurrentMessage: - Removed unused import for 'mdast'. - Modified marginTop value to always be '1em' instead of conditionally set based on chat.responsed. MessageList: - Updated the usage of MessageBody to pass the messageText as children prop. MessageMarkdown: - Updated the code component to determine the 'done' prop based on the index and the presence of 'code' nodes. Note: The changes in the components involve refactoring and improving the code structure and functionality.
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { Container, createStyles } from "@mantine/core";
|
|
import React from "react";
|
|
import { observer } from "mobx-react-lite";
|
|
import MessageMarkdown from "@/views/components/MessageMarkdown";
|
|
import { useMst } from "@/views/stores/RootStore";
|
|
|
|
interface IProps {
|
|
messageType: string,
|
|
children: string,
|
|
temp?: boolean
|
|
}
|
|
|
|
|
|
const useStyles = createStyles((theme, options:any) => ({
|
|
bodyWidth:{
|
|
width: options.chatPanelWidth - 20,
|
|
}
|
|
}));
|
|
|
|
const MessageBody = observer((props: IProps) => {
|
|
const { children, messageType, temp=false } = props;
|
|
const { chat } = useMst();
|
|
const {classes} = useStyles({
|
|
chatPanelWidth:chat.chatPanelWidth
|
|
});
|
|
return (
|
|
messageType === 'bot'
|
|
? <MessageMarkdown className={classes.bodyWidth} temp={temp}>
|
|
{children}
|
|
</MessageMarkdown>
|
|
: <Container
|
|
sx={{
|
|
margin: 0,
|
|
padding: 0,
|
|
width: chat.chatPanelWidth - 20,
|
|
pre: {
|
|
whiteSpace: 'pre-wrap',
|
|
wordBreak: 'break-word',
|
|
},
|
|
}}>
|
|
<pre>{children}</pre>
|
|
</Container>
|
|
);
|
|
});
|
|
|
|
export default MessageBody; |