import ReactMarkdown from 'react-markdown'; import { Link } from 'react-router-dom'; import remarkGfm from 'remark-gfm'; import { Hashtag, ImagePreview, LinkPreview, MentionNote, MentionUser, VideoPreview, } from '@shared/notes'; import { parser } from '@utils/parser'; export function TextNote({ content }: { content: string }) { const richContent = parser(content) ?? null; if (!richContent) { return (
{content}
); } return (
{ const cleanURL = new URL(href); cleanURL.search = ''; return ( {cleanURL.hostname + cleanURL.pathname} ); }, del: ({ children }) => { const key = children[0] as string; if (typeof key !== 'string') return; if (key.startsWith('pub') && key.length > 50 && key.length < 100) { return ; } if (key.startsWith('tag')) { return ; } }, }} disallowedElements={['h1', 'h2', 'h3', 'h4', 'h5', 'h6']} unwrapDisallowed={true} linkTarget={'_blank'} > {richContent.parsed}
{richContent.images.length > 0 && } {richContent.videos.length > 0 && } {richContent.links.length > 0 && } {richContent.notes.length > 0 && richContent.notes.map((note: string) => )}
); }