Skip to content

Commit

Permalink
chore: Message 機能で Markdown の描画に対応させる
Browse files Browse the repository at this point in the history
  • Loading branch information
rito528 committed Nov 10, 2024
1 parent 2cfba20 commit 309c817
Show file tree
Hide file tree
Showing 4 changed files with 862 additions and 5 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.45.4",
"react-markdown": "^9.0.1",
"remark-gfm": "^4.0.0",
"swr": "^2.2.5",
"ts-pattern": "^5.0.6",
"zod": "^3.22.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { errorResponseSchema } from '@/app/api/_schemas/ResponseSchemas';
import { formatString } from '@/generic/DateFormatter';
import type { ErrorResponse } from '@/app/api/_schemas/ResponseSchemas';
import type { Either } from 'fp-ts/lib/Either';
import Markdown from 'react-markdown';
import remarkGfm from 'remark-gfm';

type Message = {
id: string;
Expand Down Expand Up @@ -181,9 +183,11 @@ const Message = (props: {
}}
/>
) : (
<Typography sx={{ whiteSpace: 'pre-wrap' }}>
{props.message.body}
</Typography>
<Box sx={{ whiteSpace: 'pre-wrap' }}>
<Markdown remarkPlugins={[remarkGfm]}>
{props.message.body}
</Markdown>
</Box>
)}
</Grid>
{operationResultMessage === undefined ? null : (
Expand Down
24 changes: 24 additions & 0 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,30 @@ body {
rgb(var(--background-start-rgb));
}

code {
background-color: #343434;
padding: 0.1em 0.3em;
}

div:has(> blockquote) {
border-left: 0.3em solid #343434;
margin: 10px auto;
padding: 15px;
border-radius: 5px;
}

blockquote p::before {
content: '\201C';
}

blockquote p::after {
content: '\201D';
}

blockquote + p {
text-align: right;
}

@media (prefers-color-scheme: dark) {
html {
color-scheme: dark;
Expand Down
Loading

0 comments on commit 309c817

Please sign in to comment.