diff --git a/src/components/App.tsx b/src/components/App.tsx index cb92034..e46d0ab 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -93,6 +93,17 @@ export function App() { }, }, }, + Code: { + styles: (theme) => ({ + root: { + fontSize: theme.fontSizes.sm, + backgroundColor: + theme.colorScheme == "dark" + ? theme.colors.dark[7] + : theme.colors.gray[1], + }, + }), + }, }, }} > diff --git a/src/components/MessageItem.tsx b/src/components/MessageItem.tsx index 2eb8165..fe0a1ab 100644 --- a/src/components/MessageItem.tsx +++ b/src/components/MessageItem.tsx @@ -2,6 +2,8 @@ import { ActionIcon, Box, Card, + Code, + CopyButton, Flex, Table, Text, @@ -41,9 +43,38 @@ export function MessageItem({ message }: { message: Message }) { children={message.content} remarkPlugins={[remarkGfm]} components={{ - table: (props) => ( + table: ({ node, ...props }) => ( ), + code: ({ node, inline, ...props }) => + inline ? ( + + ) : ( + + + + {({ copied, copy }) => ( + + + + + + )} + + + ), }} /> {message.role === "assistant" && ( diff --git a/src/styles/markdown.scss b/src/styles/markdown.scss index a8f6793..5275431 100644 --- a/src/styles/markdown.scss +++ b/src/styles/markdown.scss @@ -7,11 +7,6 @@ margin-bottom: 0; } } - pre { - overflow-x: auto; - padding: 8px 12px; - border-radius: 8px; - } ul { padding-left: 20px; } @@ -19,21 +14,3 @@ padding-left: 4px; } } - -.dark-theme { - .markdown { - pre { - background-color: var(--mantine-color-dark-7); - color: var(--mantine-color-white); - } - } -} - -.light-theme { - .markdown { - pre { - background-color: var(--mantine-color-gray-1); - color: var(--mantine-color-dark-4); - } - } -} \ No newline at end of file