/* 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}
), a: ({ children, ...props }) => ( {children} ), ul: ({ children, ...props }) => ({children}), hr: props =>
{children}
),
code: ({ className, children, ...props }) => {
const match = /language-(\w+)/.exec(className || '');
return match ? (
{children}
);
},
em: ({ children, ...props }) => (
{children}
),
strong: ({ children, ...props }) => (
{children}
),
del: ({ children, ...props }) => (