fix: memory leak lowlight dep

This commit is contained in:
Faisal Amir 2024-11-27 01:17:14 +07:00
parent b046ee3e22
commit bf9bdded9f
2 changed files with 8 additions and 2 deletions

View File

@ -38,7 +38,7 @@
"react-icons": "^4.12.0",
"react-markdown": "^9.0.1",
"react-toastify": "^9.1.3",
"rehype-highlight": "^7.0.1",
"rehype-highlight": "^6.0.0",
"rehype-highlight-code-lines": "^1.0.4",
"rehype-katex": "^7.0.1",
"rehype-raw": "^7.0.0",

View File

@ -95,6 +95,7 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
// Join the lines with newline characters for proper formatting
return codeLines.join('\n')
}
function wrapCodeBlocksWithoutVisit() {
return (tree: { children: any[] }) => {
tree.children = tree.children.map((node) => {
@ -394,7 +395,12 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
rehypePlugins={[
[rehypeKatex, { throwOnError: false }],
rehypeRaw,
rehypeHighlight,
[
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
rehypeHighlight,
{ subset: false, plainText: ['txt', 'text'] },
],
[rehypeHighlightCodeLines, { showLineNumbers: true }],
wrapCodeBlocksWithoutVisit,
]}