From 8bd1dc5144d3ffb596e0b01cddc0f8dd0e07073b Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Mon, 17 Jun 2024 12:59:05 +0200 Subject: [PATCH] layout fix --- .../ItemPopupComponents/TextView.tsx | 105 ++++++++++-------- .../Templates/OverlayItemsIndexPage.tsx | 44 ++++---- 2 files changed, 84 insertions(+), 65 deletions(-) diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx index c5a9352d..afb5fded 100644 --- a/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx @@ -1,24 +1,24 @@ -import * as React from 'react' -import { Item } from '../../../../types' +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 Markdown from 'react-markdown'; import { getValue } from '../../../../Utils/GetValue'; -import remarkBreaks from 'remark-breaks' +import remarkBreaks from 'remark-breaks'; import { decodeTag } from '../../../../Utils/FormatTags'; -export const TextView = ({ item, truncate = false, itemTextField}: { item?: Item, truncate?: boolean,itemTextField?: string }) => { +export const TextView = ({ item, truncate = false, itemTextField }: { item?: Item, truncate?: boolean, itemTextField?: string }) => { const tags = useTags(); - const addFilterTag = useAddFilterTag(); + const addFilterTag = useAddFilterTag(); let text = ""; - if(itemTextField && item) text = getValue(item, itemTextField); - else text = item?.layer?.itemTextField && item ? getValue(item, item.layer?.itemTextField) : "" + if (itemTextField && item) text = getValue(item, itemTextField); + else text = item?.layer?.itemTextField && item ? getValue(item, item.layer?.itemTextField) : ""; - if(item && text && truncate) text = truncateString(text, 100, true); + if (item && text && truncate) text = truncateText(removeMarkdownKeepLinksAndParagraphs(text), 100); let replacedText; @@ -32,19 +32,17 @@ export const TextView = ({ item, truncate = false, itemTextField}: { item?: Item if (url.match('^http:\/\/')) { shortUrl = url.split('http://')[1]; } - return `[${shortUrl}](${url})` - }) : "" ; + return `[${shortUrl}](${url})`; + }) : ""; replacedText ? replacedText = replacedText.replace(mailRegex, (url) => { - return `[${url}](mailto:${url})` + return `[${url}](mailto:${url})`; }) : ""; replacedText ? replacedText = replacedText.replace(hashTagRegex, (match) => { - return `[${match}](${match})` + return `[${match}](${match})`; }) : ""; - - const CustomH1 = ({ children }) => (

{children}

); @@ -89,43 +87,37 @@ export const TextView = ({ item, truncate = false, itemTextField}: { item?: Item target='_blank' > {children} ); - const CustomHashTagLink = ({ children, tag, item }) => { + const CustomHashTagLink = ({ children, tag, item }) => { return ( - { - e.stopPropagation(); - addFilterTag(tag!); - // map.fitBounds(items) - // map.closePopup(); - }}>{decodeTag(children)} - )}; - + { + e.stopPropagation(); + addFilterTag(tag!); + }}>{decodeTag(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 videoId = href?.split('v=')[1].split('&')[0]; const youtubeEmbedUrl = `https://www.youtube-nocookie.com/embed/${videoId}`; return ( -