import * as React from 'react' import { Item } from '../../../../types' import { useTags } from '../../hooks/useTags'; import { useAddFilterTag } from '../../hooks/useFilter'; import { hashTagRegex } from '../../../../Utils/HashTagRegex'; import { fixUrls, mailRegex } from '../../../../Utils/ReplaceURLs'; import Markdown from 'react-markdown' import rehypeVideo from 'rehype-video'; import { getValue } from '../../../../Utils/GetValue'; export const TextView = ({ item, truncate = false}: { item?: Item, truncate?: boolean }) => { const tags = useTags(); const addFilterTag = useAddFilterTag(); let text = item?.layer?.itemTextField && item ? getValue(item, item.layer?.itemTextField) : ""; if(item && text && truncate) text = truncateString(text, 100, true); let replacedText; item && text ? replacedText = fixUrls(text) : ""; 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})` }) : "" ; replacedText ? replacedText = replacedText.replace(mailRegex, (url) => { return `[${url}](mailto:${url})` }) : ""; 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} ); const CustomImage = ({ alt, src, title }) => ( {alt} ); const CustomExternalLink = ({ href, children }) => ( {children} ); const CustomHashTagLink = ({ children, tag, item }) => { return ( { e.stopPropagation(); addFilterTag(tag!); // map.fitBounds(items) // map.closePopup(); }}>{children} )}; return ( //@ts-ignore { // Prüft, ob der Link ein YouTube-Video ist const isYouTubeVideo = href?.startsWith('https://www.youtube.com/watch?v='); if (isYouTubeVideo) { const videoId = href?.split('v=')[1].split('&')[0]; // Extrahiert die Video-ID aus der URL const youtubeEmbedUrl = `https://www.youtube-nocookie.com/embed/${videoId}`; return (