From 92a6379e2c645bdf8a56484a9ab500ba6c5a07b2 Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Mon, 16 Dec 2024 10:39:38 +0100 Subject: [PATCH] ui: fix prismjs loading --- frontend/app/assets/index.html | 9 ++++++ .../app/components/ui/CodeBlock/CodeBlock.tsx | 28 +++++++++---------- frontend/babel.config.js | 16 ----------- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/frontend/app/assets/index.html b/frontend/app/assets/index.html index edb51ad24..4c037eec1 100644 --- a/frontend/app/assets/index.html +++ b/frontend/app/assets/index.html @@ -14,6 +14,15 @@ + + + + + + + diff --git a/frontend/app/components/ui/CodeBlock/CodeBlock.tsx b/frontend/app/components/ui/CodeBlock/CodeBlock.tsx index 176cd1cfb..ae5c7c6dd 100644 --- a/frontend/app/components/ui/CodeBlock/CodeBlock.tsx +++ b/frontend/app/components/ui/CodeBlock/CodeBlock.tsx @@ -1,20 +1,20 @@ -import React, { useEffect } from "react"; -import Prism from "prismjs"; +import React, { useEffect } from 'react'; -interface IProps { - code: string; - language: string; -} - -const CodeBlock = ({ code, language }: IProps) => { +export default function CodeBlock({ code }) { + const language = 'javascript' useEffect(() => { - Prism.highlightAll(false); - }, []); + setTimeout(() => { + if (window.Prism) { + Prism.highlightAll(); + } + }, 0) + }, [code, language]); + return (
-      
+      
+        {code}
+      
     
); -}; - -export default CodeBlock; \ No newline at end of file +} diff --git a/frontend/babel.config.js b/frontend/babel.config.js index 16518fa23..aaf309964 100644 --- a/frontend/babel.config.js +++ b/frontend/babel.config.js @@ -7,21 +7,5 @@ module.exports = { plugins: [ 'babel-plugin-react-require', ['@babel/plugin-proposal-decorators', { legacy: true }], - [ - 'prismjs', - { - languages: [ - 'javascript', - 'css', - 'bash', - 'typescript', - 'jsx', - 'kotlin', - 'swift', - ], - theme: 'default', - css: true, - }, - ], ], };