diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx
index 5ff21325..508e210f 100644
--- a/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx
+++ b/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx
@@ -4,7 +4,6 @@
/* 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'
@@ -26,14 +25,12 @@ export const TextView = ({
text,
truncate = false,
rawText,
- itemTextField,
}: {
item?: Item
itemId?: string
text?: string
truncate?: boolean
rawText?: string
- itemTextField?: string
}) => {
if (item) {
text = item.text
@@ -41,8 +38,6 @@ export const TextView = ({
}
const tags = useTags()
const addFilterTag = useAddFilterTag()
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- const itemTextFieldDummy = itemTextField
let innerText = ''
let replacedText = ''
@@ -86,53 +81,15 @@ export const TextView = ({
})
}
- 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 }) => (
-
- )
-
- const CustomExternalLink = ({ href, children }) => (
-
- {' '}
- {children}
-
- )
-
- const CustomHashTagLink = ({
- children,
- tag,
- itemId,
- }: {
- children: string
- tag: Tag
- itemId?: string
- }) => {
+ const HashTag = ({ children, tag, itemId }: { children: string; tag: Tag; itemId?: string }) => {
return (
{
e.stopPropagation()
@@ -144,62 +101,48 @@ export const TextView = ({
)
}
- // eslint-disable-next-line react/display-name
- const MemoizedVideoEmbed = memo(({ url }: { url: string }) => (
-
- ))
+ const Link = ({ href, children }: { href: string; children: string }) => {
+ // Youtube
+ if (href.startsWith('https://www.youtube.com/watch?v=')) {
+ const videoId = href?.split('v=')[1].split('&')[0]
+ const youtubeEmbedUrl = `https://www.youtube-nocookie.com/embed/${videoId}`
+
+ return (
+
+ )
+ }
+
+ // Rumble
+ if (href.startsWith('https://rumble.com/embed/')) {
+ return
+ }
+
+ // HashTag
+ if (href.startsWith('#')) {
+ const tag = tags.find((t) => t.name.toLowerCase() === decodeURI(href).slice(1).toLowerCase())
+ if (tag)
+ return (
+
+ {children}
+
+ )
+ else return children
+ }
+
+ // Default: Link
+ return (
+
+ {children}
+
+ )
+ }
return (
{
- const isYouTubeVideo = href?.startsWith('https://www.youtube.com/watch?v=')
-
- const isRumbleVideo = href?.startsWith('https://rumble.com/embed/')
-
- if (isYouTubeVideo) {
- const videoId = href?.split('v=')[1].split('&')[0]
- const youtubeEmbedUrl = `https://www.youtube-nocookie.com/embed/${videoId}`
-
- return
- }
- if (isRumbleVideo) {
- return
- }
-
- if (href?.startsWith('#')) {
- const tag = tags.find(
- (t) => t.name.toLowerCase() === decodeURI(href).slice(1).toLowerCase(),
- )
- if (tag)
- return (
-
- {children}
-
- )
- else return children
- } else {
- return {children}
- }
- },
- ul: CustomUnorderdList,
- ol: CustomOrderdList,
- img: CustomImage,
- hr: CustomHorizontalRow,
- h1: CustomH1,
- h2: CustomH2,
- h3: CustomH3,
- h4: CustomH4,
- h5: CustomH5,
- h6: CustomH6,
+ a: Link,
}}
>
{replacedText}
diff --git a/src/assets/css/markdown.css b/src/assets/css/markdown.css
new file mode 100644
index 00000000..e6a1fbf1
--- /dev/null
+++ b/src/assets/css/markdown.css
@@ -0,0 +1,63 @@
+@import 'tailwindcss' prefix(tw);
+
+@layer markdown {
+ .markdown h1 {
+ @apply tw:text-xl;
+ @apply tw:font-bold;
+ }
+
+ .markdown h2 {
+ @apply tw:text-lg;
+ @apply tw:font-bold;
+ }
+
+ .markdown h3, .markdown h4 {
+ @apply tw:text-base;
+ @apply tw:font-bold;
+ }
+
+ .markdown h5, .markdown h6 {
+ @apply tw:text-sm;
+ @apply tw:font-bold;
+ }
+
+ .markdown p {
+ @apply tw:my-2!;
+ }
+
+ .markdown ul {
+ @apply tw:list-disc;
+ @apply tw:list-inside;
+ }
+
+ .markdown ol {
+ @apply tw:list-decimal;
+ @apply tw:list-inside;
+ }
+
+ .markdown hl {
+ @apply tw:border-current;
+ }
+
+ .markdown img {
+ @apply tw:max-w-full;
+ @apply tw:rounded;
+ @apply tw:shadow;
+ }
+
+ .markdown a {
+ @apply tw:font-bold;
+ @apply tw:underline;
+ }
+
+ .markdown .hashtag {
+ color: #faa;
+ font-weight: bold;
+ cursor: pointer;
+ text-decoration: none;
+ }
+
+ .markdown iframe {
+ @apply tw:w-full;
+ }
+}
\ No newline at end of file
diff --git a/src/css.tsx b/src/css.tsx
index 5856b54a..40996d95 100644
--- a/src/css.tsx
+++ b/src/css.tsx
@@ -13,3 +13,4 @@ import '#assets/css/misc.css'
import '#assets/css/marker-icons.css'
import '#assets/css/leaflet.css'
import '#assets/css/color-picker.css'
+import '#assets/css/markdown.css'