From bf9bdded9f2a90033b6db7c76c90b8f8fa2e3d81 Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Wed, 27 Nov 2024 01:17:14 +0700 Subject: [PATCH] fix: memory leak lowlight dep --- web/package.json | 2 +- .../Thread/ThreadCenterPanel/SimpleTextMessage/index.tsx | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/web/package.json b/web/package.json index 24c47e53c..e59fa2651 100644 --- a/web/package.json +++ b/web/package.json @@ -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", diff --git a/web/screens/Thread/ThreadCenterPanel/SimpleTextMessage/index.tsx b/web/screens/Thread/ThreadCenterPanel/SimpleTextMessage/index.tsx index 61a26e60d..5df69966f 100644 --- a/web/screens/Thread/ThreadCenterPanel/SimpleTextMessage/index.tsx +++ b/web/screens/Thread/ThreadCenterPanel/SimpleTextMessage/index.tsx @@ -95,6 +95,7 @@ const SimpleTextMessage: React.FC = (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 = (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, ]}