import ReactMarkdown from 'react-markdown'; import rehypeRaw from 'rehype-raw'; import { replaceStr, mergeReplaceToDiv } from '../../utils/tools'; import { Popover } from 'antd'; import classNames from 'classnames'; import styles from './index.module.less'; import { useEffect } from 'react'; interface IMarkdownProps { source: string; refList?: any; quoType?: string; chatIsOver?: boolean; } const CustomMarkdown = ({ source, refList = null, quoType = 'single', chatIsOver = false }: IMarkdownProps) => { const linkToExtend = (url: string) => { window.open(url); }; const CustomI = ({ children, className, ...props }: any) => { const content = refList ? Object.keys(refList).map((item) => { if (Number(item) === Number(children)) { return (
  • { linkToExtend(refList[item].url); }} >
    {refList[item].url}
    {refList[item].title}
    {refList[item].summ}
  • ); } else { return null; } }) : null; return className.includes('custom') ? ( {children} ) : ( {children} ); }; const CustomDiv = ({ children, className, ...props }: any) => { const list = props['data-ids'].split(','); const content = refList ? Object.keys(refList).map((item) => { if (list.includes(String(item))) { return ( <>
  • { linkToExtend(refList[item].url); }} >
    {refList[item].url}
    {refList[item].title}
  • ); } else { return null; } }) : null; return className.includes('mergeQuo') ? ( ) : ( {children} ); }; return (
    { refList ? quoType === 'merge' ? mergeReplaceToDiv(source) : replaceStr(source) : source }
    ); }; export default CustomMarkdown;