/* eslint-disable react/no-unstable-nested-components */ import React, { useEffect, useState } from 'react'; import type { Options as RMOptions } from 'react-markdown'; import ReactMarkdown from 'react-markdown'; import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism'; import remarkGfm from 'remark-gfm'; const changelog = new URL('/CHANGELOG.md', import.meta.url).href; /** * Renders a popup component for displaying the changelog. * * @param isOpen - A boolean indicating whether the popup is open or not. * @param onClose - A function to be called when the popup is closed. * * @returns The JSX element representing the ChangelogPopup component. */ export default function ChangelogPopup(): JSX.Element { const [markdownContent, setMarkdownContent] = useState(''); useEffect(() => { fetch(changelog) .then(response => response.text()) .then(text => setMarkdownContent(text)) .catch(error => console.error('Error fetching changelog:', error)); }, []); const MarkdownComponents: RMOptions['components'] = { h1: ({ children, ...props }) => (

{children}

), h2: ({ children, ...props }) => (

{children}

), h3: ({ children, ...props }) => (

{children}

), h4: ({ children, ...props }) => (

{children}

), h5: ({ children, ...props }) => (
{children}
), h6: ({ children, ...props }) => (
{children}
), p: ({ children, ...props }) => (

{children}

), a: ({ children, ...props }) => ( {children} ), ul: ({ children, ...props }) => ( ), ol: ({ children, ...props }) => (
    {children}
), li: ({ children, ...props }) => (
  • {children}
  • ), blockquote: ({ children, ...props }) => (
    {children}
    ), hr: props =>
    , table: ({ children, ...props }) => (
    {children}
    ), thead: ({ children, ...props }) => ( {children} ), tbody: ({ children, ...props }) => ( {children} ), tr: ({ children, ...props }) => ( {children} ), th: ({ children, ...props }) => ( {children} ), td: ({ children, ...props }) => ( {children} ), pre: ({ children, ...props }) => (
                    {children}
                
    ), code: ({ className, children, ...props }) => { const match = /language-(\w+)/.exec(className || ''); return match ? ( {String(children).replace(/\n$/, '')} ) : ( {children} ); }, em: ({ children, ...props }) => ( {children} ), strong: ({ children, ...props }) => ( {children} ), del: ({ children, ...props }) => ( {children} ), img: ({ src, alt, ...props }) => ( {alt} ), }; return (
    {markdownContent}
    ); }