Skip to content

Commit

Permalink
Merge branch 'feat/rever-agent-message' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Wangtaofeng committed Mar 1, 2024
2 parents 3313bbd + 8f6cd82 commit 2a5bb6d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/builder/src/page/AI/components/MarkdownMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
markdownMessageStyle,
} from "@/page/AI/components/MarkdownMessage/style"
import Code from "./Code"
import { handleMarkdownLine } from "./utils"

export const MarkdownMessage: FC<MarkdownMessageProps> = (props) => {
const { children, isOwnMessage } = props
Expand Down Expand Up @@ -64,7 +65,6 @@ export const MarkdownMessage: FC<MarkdownMessageProps> = (props) => {
<Typography>
<ReactMarkdown
css={markdownMessageStyle}
// disallowedElements={["table", "thead", "tbody", "tr", "th", "td"]}
remarkPlugins={[remarkGfm, remarkBreaks]}
components={{
h1: ({ children }) => <Heading level="h1">{children}</Heading>,
Expand Down Expand Up @@ -99,7 +99,7 @@ export const MarkdownMessage: FC<MarkdownMessageProps> = (props) => {
code: (props) => <Code {...props} />,
}}
>
{(children ?? "").replaceAll(/(^---\r?\n?)/gm, "\n---\n")}
{handleMarkdownLine(children ?? "")}
</ReactMarkdown>
</Typography>
</div>
Expand Down
4 changes: 4 additions & 0 deletions apps/builder/src/page/AI/components/MarkdownMessage/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,7 @@ export const getTextValue = (value: unknown): string => {
return ""
}
}

export const handleMarkdownLine = (text: string) => {
return text.replace(/((^\n?---)(\n|$))/gm, "\n---\n")
}

0 comments on commit 2a5bb6d

Please sign in to comment.