From 607b25aa62cb20f429bbbd407f0ff59e49c0155c Mon Sep 17 00:00:00 2001 From: JK-le-dev Date: Sun, 19 Oct 2025 00:00:08 -0500 Subject: [PATCH] refactor(markdown): changed markdown conf loc --- .../src/components/ui/chat/chat-window.jsx | 5 +- web-app/src/config/markdown.jsx | 60 +++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 web-app/src/config/markdown.jsx diff --git a/web-app/src/components/ui/chat/chat-window.jsx b/web-app/src/components/ui/chat/chat-window.jsx index aad1c7b..2b78ce2 100644 --- a/web-app/src/components/ui/chat/chat-window.jsx +++ b/web-app/src/components/ui/chat/chat-window.jsx @@ -1,5 +1,6 @@ import React, { useRef, useEffect } from "react"; import ReactMarkdown from "react-markdown"; +import { MARKDOWN_COMPONENTS } from "src/config/markdown"; function MessageBubble({ message }) { const isUser = message.role === "user"; @@ -11,7 +12,9 @@ function MessageBubble({ message }) { {isUser ? (
{message.content}
) : ( - {message.content} + + {message.content} + )} diff --git a/web-app/src/config/markdown.jsx b/web-app/src/config/markdown.jsx new file mode 100644 index 0000000..c0ea78f --- /dev/null +++ b/web-app/src/config/markdown.jsx @@ -0,0 +1,60 @@ +export const MARKDOWN_COMPONENTS = { + h1: ({ node, ...props }) => ( +

+ ), + h2: ({ node, ...props }) => ( +

+ ), + h3: ({ node, ...props }) => ( +

+ ), + p: ({ node, ...props }) => ( +

+ ), + a: ({ node, href, ...props }) => ( + + ), + code: ({ node, inline, className, children, ...props }) => { + if (inline) { + return ( + + {children} + + ); + } + return ( +

+        {children}
+      
+ ); + }, + blockquote: ({ node, ...props }) => ( +
+ ), + ul: ({ node, ...props }) => ( +
    + ), + ol: ({ node, ...props }) => ( +
      + ), + li: ({ node, ...props }) =>
    1. , + strong: ({ node, ...props }) => ( + + ), + em: ({ node, ...props }) => , +};