feat: supports the display of line breaks in Markdown

This commit is contained in:
RugerMc 2023-03-29 17:19:30 +08:00
parent cfbe6d77b5
commit b94607f636
6 changed files with 8 additions and 5 deletions

View File

@ -128,7 +128,7 @@ function useSubmitHandler() {
const shouldSubmit = (e: KeyboardEvent) => { const shouldSubmit = (e: KeyboardEvent) => {
if (e.key !== "Enter") return false; if (e.key !== "Enter") return false;
return ( return (
(config.submitKey === SubmitKey.AltEnter && e.altKey) || (config.submitKey === SubmitKey.AltEnter && e.altKey) ||
(config.submitKey === SubmitKey.CtrlEnter && e.ctrlKey) || (config.submitKey === SubmitKey.CtrlEnter && e.ctrlKey) ||

View File

@ -34,6 +34,7 @@ export function Markdown(props: { content: string }) {
components={{ components={{
pre: PreCode, pre: PreCode,
}} }}
className="line-break"
> >
{props.content} {props.content}
</ReactMarkdown> </ReactMarkdown>

View File

@ -17,7 +17,7 @@ const cn = {
Retry: "重试", Retry: "重试",
}, },
Typing: "正在输入…", Typing: "正在输入…",
Input: (submitKey: string) => `输入消息,${submitKey} 发送`, Input: (submitKey: string) => `输入消息,${submitKey} 发送, Shift + Enter 换行`,
Send: "发送", Send: "发送",
}, },
Export: { Export: {

View File

@ -20,8 +20,7 @@ const en: LocaleType = {
Retry: "Retry", Retry: "Retry",
}, },
Typing: "Typing…", Typing: "Typing…",
Input: (submitKey: string) => Input: (submitKey: string) => `Type something and press ${submitKey} to send, press Shift + Enter to newline`,
`Type something and press ${submitKey} to send`,
Send: "Send", Send: "Send",
}, },
Export: { Export: {

View File

@ -19,7 +19,7 @@ const tw: LocaleType = {
Retry: "重試", Retry: "重試",
}, },
Typing: "正在輸入…", Typing: "正在輸入…",
Input: (submitKey: string) => `輸入訊息後,按下 ${submitKey} 鍵即可發送`, Input: (submitKey: string) => `輸入訊息後,按下 ${submitKey} 鍵即可發送, Shift + Enter 鍵換行`,
Send: "發送", Send: "發送",
}, },
Export: { Export: {

View File

@ -1117,3 +1117,6 @@
.markdown-body ::-webkit-calendar-picker-indicator { .markdown-body ::-webkit-calendar-picker-indicator {
filter: invert(50%); filter: invert(50%);
} }
.markdown-body .line-break {
white-space: pre-wrap;
}