fix: markdown view \n do not work

This commit is contained in:
jialin
2025-08-13 19:50:54 +08:00
parent 0af8e34a8f
commit 2ca712435a
7 changed files with 37 additions and 13 deletions
@@ -255,7 +255,7 @@ const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => {
return () => {
chunkRequedtRef.current?.current?.abort?.();
};
}, [url]);
}, [url, isDownloading]);
useEffect(() => {
debouncedScroll();
@@ -357,4 +357,4 @@ const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => {
);
});
export default React.memo(LogsViewer);
export default LogsViewer;
@@ -3,6 +3,7 @@ import 'katex/dist/katex.min.css';
import React, { useMemo } from 'react';
import ReactMarkdown from 'react-markdown';
import rehypeKatex from 'rehype-katex';
import remarkBreaks from 'remark-breaks';
import remarkGfm from 'remark-gfm';
import remarkMath from 'remark-math';
import styled from 'styled-components';
@@ -17,9 +18,7 @@ interface FullMarkdownProps {
const Wrapper = styled.div.attrs(() => ({
className: 'markdown-viewer'
}))`
line-height: 2;
`;
}))``;
const CodeViewer = (props: any) => {
const { children, className, node, theme, ...rest } = props;
@@ -41,7 +40,7 @@ const FullMarkdown: React.FC<FullMarkdownProps> = ({ content, theme }) => {
return (
<Wrapper>
<ReactMarkdown
remarkPlugins={[[remarkMath], remarkGfm]}
remarkPlugins={[[remarkMath], remarkGfm, remarkBreaks]}
rehypePlugins={[rehypeKatex]}
components={{
code(props) {
+1 -3
View File
@@ -1,6 +1,6 @@
.markdown-viewer {
word-break: break-word;
white-space: pre-line;
line-height: 2;
font-size: var(--font-size-base);
.hr {
@@ -61,13 +61,11 @@
ul {
margin-bottom: 0;
padding-left: 20px;
line-height: 2;
}
ol {
margin-bottom: 0;
padding-left: 20px;
line-height: 2;
}
a * {