/* eslint-disable no-console */ /* eslint-disable @typescript-eslint/no-unnecessary-condition */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/restrict-plus-operands */ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-call */ import { memo } from 'react' import Markdown from 'react-markdown' import remarkBreaks from 'remark-breaks' import { useAddFilterTag } from '#components/Map/hooks/useFilter' import { useTags } from '#components/Map/hooks/useTags' import { decodeTag } from '#utils/FormatTags' import { hashTagRegex } from '#utils/HashTagRegex' import { fixUrls, mailRegex } from '#utils/ReplaceURLs' import type { Item } from '#types/Item' import type { Tag } from '#types/Tag' export const TextView = ({ item, itemId, text, truncate = false, rawText, }: { item: Item itemId: string text?: string truncate?: boolean rawText?: string }) => { if (item) { text = item.text itemId = item.id } const tags = useTags() const addFilterTag = useAddFilterTag() let innerText = '' let replacedText = '' if (rawText) { innerText = replacedText = rawText } else if (text) { innerText = text } if (innerText && truncate) innerText = truncateText(removeMarkdownKeepLinksAndParagraphs(innerText), 100) if (innerText) replacedText = fixUrls(innerText) if (replacedText) { replacedText = replacedText.replace(/(? { let shortUrl = url if (url.match('^https://')) { shortUrl = url.split('https://')[1] } if (url.match('^http://')) { shortUrl = url.split('http://')[1] } return `[${shortUrl}](${url})` }) } if (replacedText) { replacedText = replacedText.replace(mailRegex, (url) => { return `[${url}](mailto:${url})` }) } if (replacedText) { replacedText = replacedText.replace(hashTagRegex, (match) => { return `[${match}](${match})` }) } const CustomH1 = ({ children }) =>

{children}

const CustomH2 = ({ children }) =>

{children}

const CustomH3 = ({ children }) =>

{children}

const CustomH4 = ({ children }) =>

{children}

const CustomH5 = ({ children }) =>
{children}
const CustomH6 = ({ children }) =>
{children}
const CustomParagraph = ({ children }) =>

{children}

const CustomUnorderdList = ({ children }) => ( ) const CustomOrderdList = ({ children }) => (
    {children}
) const CustomHorizontalRow = ({ children }) =>
{children} // eslint-disable-next-line react/prop-types const CustomImage = ({ alt, src, title }) => ( {alt} ) const CustomExternalLink = ({ href, children }) => ( {' '} {children} ) const CustomHashTagLink = ({ children, tag, itemId, }: { children: string tag: Tag itemId: string }) => { return ( { e.stopPropagation() addFilterTag(tag) }} > {decodeTag(children)} ) } // eslint-disable-next-line react/display-name const MemoizedVideoEmbed = memo(({ url }: { url: string }) => (