import { memo } from 'react'; import ReactMarkdown from 'react-markdown'; import { Link } from 'react-router-dom'; import remarkGfm from 'remark-gfm'; import { Boost, Hashtag, ImagePreview, Invoice, LinkPreview, MentionNote, MentionUser, VideoPreview, } from '@shared/notes'; import { parser } from '@utils/parser'; export function TextNote(props: { content?: string }) { const richContent = parser(props.content) ?? null; if (!richContent) { return (
{props.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 ; } if (key.startsWith('boost')) { return ; } if (key.startsWith('lnbc')) { return ; } }, }} disallowedElements={['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'code']} 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) => )}
); } export const MemoizedTextNote = memo(TextNote);