/* eslint-disable react/no-array-index-key */ import type { CSSProperties } from 'react'; import UserLink from '../UserInfo/link'; export interface MentionTextProps { text: string; /** 分隔符,默认为(' ') */ split?: string; /** 弃用文本,会覆盖text文本 */ discard?: string; style?: CSSProperties; } const MentionText = (props: MentionTextProps) => { const { text, split = ' ', discard, style } = props; return (
{discard || text.split(split).map((item, index) => { const marginLeft = index === 0 ? 0 : 4; const res = /@([^(]+)\(([^)]+)\)/g.exec(item); if (res && res[0] === item) { const [, nameZh, account] = res; return (