import styles from './text.module.css' import ReactMarkdown from 'react-markdown' import gfm from 'remark-gfm' import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter' import { atomDark } from 'react-syntax-highlighter/dist/cjs/styles/prism' import mention from '../lib/remark-mention' import sub from '../lib/remark-sub' import remarkDirective from 'remark-directive' import { visit } from 'unist-util-visit' import reactStringReplace from 'react-string-replace' import React, { useEffect, useState } from 'react' import GithubSlugger from 'github-slugger' import Link from '../svgs/link.svg' function copyToClipboard (id) { if (navigator && navigator.clipboard && navigator.clipboard.writeText) return navigator.clipboard.writeText(str); return Promise.reject('The Clipboard API is not available.'); } function myRemarkPlugin () { return (tree) => { visit(tree, (node) => { if ( node.type === 'textDirective' || node.type === 'leafDirective' ) { if (node.name !== 'high') return const data = node.data || (node.data = {}) data.hName = 'mark' data.hProperties = {} } }) } } function Heading ({ h, slugger, noFragments, topLevel, children, node, ...props }) { const id = noFragments ? undefined : slugger.slug(children.reduce( (acc, cur) => { if (typeof cur !== 'string') { return acc } return acc + cur.replace(/[^\w\-\s]+/gi, '') }, '')) console.log(id) return (
{reactStringReplace(String(children), /:high\[([^\]]+)\]/g, (match, i) => {
return {match}
})}
)
},
a: ({ node, href, children, ...props }) => {
children = children?.map(e =>
typeof e === 'string'
? reactStringReplace(e, /:high\[([^\]]+)\]/g, (match, i) => {
return {match}
})
: e)
return (
/* eslint-disable-next-line */
{
return match
}).join('')} {...props}
>
{children}
)
},
img: ({ node, ...props }) =>