From b94607f636789701612334b48d58a381b2cd06f7 Mon Sep 17 00:00:00 2001 From: RugerMc <550279039@qq.com> Date: Wed, 29 Mar 2023 17:19:30 +0800 Subject: [PATCH 1/2] feat: supports the display of line breaks in Markdown --- app/components/home.tsx | 2 +- app/components/markdown.tsx | 1 + app/locales/cn.ts | 2 +- app/locales/en.ts | 3 +-- app/locales/tw.ts | 2 +- app/styles/markdown.scss | 3 +++ 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/components/home.tsx b/app/components/home.tsx index 828ee191..accf76a4 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -128,7 +128,7 @@ function useSubmitHandler() { const shouldSubmit = (e: KeyboardEvent) => { if (e.key !== "Enter") return false; - + return ( (config.submitKey === SubmitKey.AltEnter && e.altKey) || (config.submitKey === SubmitKey.CtrlEnter && e.ctrlKey) || diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index 6e0e6d86..17e04231 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -34,6 +34,7 @@ export function Markdown(props: { content: string }) { components={{ pre: PreCode, }} + className="line-break" > {props.content} diff --git a/app/locales/cn.ts b/app/locales/cn.ts index 0c81c75d..12abb6c3 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -17,7 +17,7 @@ const cn = { Retry: "重试", }, Typing: "正在输入…", - Input: (submitKey: string) => `输入消息,${submitKey} 发送`, + Input: (submitKey: string) => `输入消息,${submitKey} 发送, Shift + Enter 换行`, Send: "发送", }, Export: { diff --git a/app/locales/en.ts b/app/locales/en.ts index 8eb379c2..2daf418a 100644 --- a/app/locales/en.ts +++ b/app/locales/en.ts @@ -20,8 +20,7 @@ const en: LocaleType = { Retry: "Retry", }, Typing: "Typing…", - Input: (submitKey: string) => - `Type something and press ${submitKey} to send`, + Input: (submitKey: string) => `Type something and press ${submitKey} to send, press Shift + Enter to newline`, Send: "Send", }, Export: { diff --git a/app/locales/tw.ts b/app/locales/tw.ts index 65145d89..a5f79011 100644 --- a/app/locales/tw.ts +++ b/app/locales/tw.ts @@ -19,7 +19,7 @@ const tw: LocaleType = { Retry: "重試", }, Typing: "正在輸入…", - Input: (submitKey: string) => `輸入訊息後,按下 ${submitKey} 鍵即可發送`, + Input: (submitKey: string) => `輸入訊息後,按下 ${submitKey} 鍵即可發送, Shift + Enter 鍵換行`, Send: "發送", }, Export: { diff --git a/app/styles/markdown.scss b/app/styles/markdown.scss index 0a6b3bc5..579f91c5 100644 --- a/app/styles/markdown.scss +++ b/app/styles/markdown.scss @@ -1117,3 +1117,6 @@ .markdown-body ::-webkit-calendar-picker-indicator { filter: invert(50%); } +.markdown-body .line-break { + white-space: pre-wrap; +} From 974c455bf9a20f4595dcb30d03e7247a43688250 Mon Sep 17 00:00:00 2001 From: RugerMc <550279039@qq.com> Date: Wed, 29 Mar 2023 17:53:52 +0800 Subject: [PATCH 2/2] feat: display line break hints in enter mode --- app/locales/cn.ts | 10 +++++++++- app/locales/en.ts | 9 ++++++++- app/locales/tw.ts | 9 ++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/locales/cn.ts b/app/locales/cn.ts index 12abb6c3..8449c295 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -1,3 +1,5 @@ +import { SubmitKey } from "../store/app"; + const cn = { WIP: "该功能仍在开发中……", Error: { @@ -17,7 +19,13 @@ const cn = { Retry: "重试", }, Typing: "正在输入…", - Input: (submitKey: string) => `输入消息,${submitKey} 发送, Shift + Enter 换行`, + Input: (submitKey: string) => { + var inputHints = `输入消息,${submitKey} 发送`; + if (submitKey === String(SubmitKey.Enter)) { + inputHints += ", Shift + Enter 换行"; + } + return inputHints; + }, Send: "发送", }, Export: { diff --git a/app/locales/en.ts b/app/locales/en.ts index 2daf418a..a5a6d1b1 100644 --- a/app/locales/en.ts +++ b/app/locales/en.ts @@ -1,3 +1,4 @@ +import { SubmitKey } from "../store/app"; import type { LocaleType } from "./index"; const en: LocaleType = { @@ -20,7 +21,13 @@ const en: LocaleType = { Retry: "Retry", }, Typing: "Typing…", - Input: (submitKey: string) => `Type something and press ${submitKey} to send, press Shift + Enter to newline`, + Input: (submitKey: string) => { + var inputHints = `Type something and press ${submitKey} to send`; + if (submitKey === String(SubmitKey.Enter)) { + inputHints += ", press Shift + Enter to newline"; + } + return inputHints; + }, Send: "Send", }, Export: { diff --git a/app/locales/tw.ts b/app/locales/tw.ts index a5f79011..49598dd1 100644 --- a/app/locales/tw.ts +++ b/app/locales/tw.ts @@ -1,3 +1,4 @@ +import { SubmitKey } from "../store/app"; import type { LocaleType } from "./index"; const tw: LocaleType = { @@ -19,7 +20,13 @@ const tw: LocaleType = { Retry: "重試", }, Typing: "正在輸入…", - Input: (submitKey: string) => `輸入訊息後,按下 ${submitKey} 鍵即可發送, Shift + Enter 鍵換行`, + Input: (submitKey: string) => { + var inputHints = `輸入訊息後,按下 ${submitKey} 鍵即可發送`; + if (submitKey === String(SubmitKey.Enter)) { + inputHints += ", Shift + Enter 鍵換行"; + } + return inputHints; + }, Send: "發送", }, Export: {