@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
13 lines (12 loc) • 800 B
JavaScript
import * as React from 'react';
import MarkdownTexts from './MessageMarkdownTexts';
const MessageMarkdownParagraphParser = ({ pSlot, pSlotProps, children, inProgress: inProgress, ...props }) => {
return React.Children.toArray(children).some(child => typeof child === "string" && child !== "\n") ? (React.createElement(MarkdownTexts, { inProgress: inProgress, component: pSlot, componentProps: {
...pSlotProps,
...props
} }, children)
// TODO: Images are wrapped in a <p> tag. This is not a bug and will not be fixed.
// @see https://github.com/quantizor/markdown-to-jsx/issues/209#issuecomment-417712075
) : (React.createElement(React.Fragment, { key: props.key }, children));
};
export default React.memo(MessageMarkdownParagraphParser);