Skip to content

Commit

Permalink
Use react markdown component and sb-prose styles for AI chat modal (#380
Browse files Browse the repository at this point in the history
)
  • Loading branch information
benjreinhart authored Oct 17, 2024
1 parent d0bdefc commit f3a2d3a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 51 deletions.
1 change: 1 addition & 0 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"diff": "^7.0.0",
"lucide-react": "^0.439.0",
"marked": "catalog:",
"marked-react": "^2.0.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-dropzone": "^14.2.3",
Expand Down
10 changes: 10 additions & 0 deletions packages/web/src/components/apps/markdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import MarkdownReact from 'marked-react';
import { cn } from '@srcbook/components';

export default function Markdown(props: { source: string; className?: string }) {
return (
<div className={cn('sb-prose', props.className)}>
<MarkdownReact gfm>{props.source}</MarkdownReact>
</div>
);
}
4 changes: 2 additions & 2 deletions packages/web/src/components/chat.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, cn, ScrollArea } from '@srcbook/components';
import { Markdown } from '../components/markdown';
import Markdown from './apps/markdown.js';
import { diffFiles } from './apps/lib/diff.js';
import TextareaAutosize from 'react-textarea-autosize';
import { ArrowUp, X, Paperclip, History, LoaderCircle, ViewIcon, Undo2Icon } from 'lucide-react';
Expand Down Expand Up @@ -90,7 +90,7 @@ function Chat({
</div>
);
} else if (message.type === 'plan') {
return <Markdown key={index}>{message.content}</Markdown>;
return <Markdown key={index} source={message.content} />;
} else if (message.type === 'diff') {
return <DiffBox key={index} files={message.diff} app={app} />;
}
Expand Down
49 changes: 0 additions & 49 deletions packages/web/src/components/markdown.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f3a2d3a

Please sign in to comment.