UNPKG

@plteam/chat-ui

Version:

CUI Kit is a free and open-source library for creating AI assistant chat interfaces, built with React, Material UI, and TypeScript

33 lines (32 loc) 1.34 kB
import * as React from 'react'; import { styled } from '@mui/material/styles'; import Box from '@mui/material/Box'; import MessageMarkdown from './MessageMarkdown'; import clsx from 'clsx'; import { chatClassNames } from '../../core/chatClassNames'; import { useChatContext } from '../../core/ChatGlobalContext'; export const ChatMarkdownBlockRoot = styled(Box)(({ theme }) => ({ ...theme.typography.body2, width: '100%', wordWrap: 'break-word', '& ol, p, ul': { margin: 0, }, '& div:first-child': { display: 'flex', flexDirection: 'column', gap: 16, }, '& code': { whiteSpace: 'pre-line', }, '& table': { borderCollapse: 'collapse', }, })); const MessageMarkdownBlock = ({ text, id, inProgress, ...otherProps }) => { const { processAssistantText, customMarkdownComponents } = useChatContext(); return (React.createElement(otherProps.rootComponent, { ...otherProps.rootComponentProps, className: clsx(otherProps.rootComponentProps?.className, chatClassNames.markdownParentRoot), id: id }, React.createElement(MessageMarkdown, { inProgress: inProgress, text: text, processAssistantText: processAssistantText, customMarkdownComponents: customMarkdownComponents }))); }; export default MessageMarkdownBlock;