// import { MouseEvent, useState } from 'react'; // import { useTranslation } from 'react-i18next'; import Linkify from "linkify-react"; import "linkify-plugin-mention"; import Mention from "./Message/Mention"; import URLPreview from "./Message/URLPreview"; type Props = { url?: boolean; mention?: boolean; mentionTextOnly?: boolean; mentionPopOver?: boolean; text: string; cid?: number; }; const LinkifyText = ({ url = true, mention = true, mentionTextOnly = false, mentionPopOver = true, text, cid }: Props) => { // const { t } = useTranslation(); // const return ( { if (mentionTextOnly) return <>{content}; return ( {content} ); }, url: ({ content, attributes: { href: link } }) => { // console.log("attr", link); if (!url) return <>{content}; return ( <> {content} ); }, mention: ({ content }) => { if (!mention) return <>{content}; // console.log(); if (/@[0-9]+/.test(content)) { const uid = content.trim().slice(1); return ( ); } return <>{content}; } } }} > {text} ); }; export default LinkifyText;