Browse Source

Merge pull request #148 from RugerMcCarthy/dev

supports the display of line breaks in Markdown
Yifei Zhang 1 year ago
parent
commit
525b5b8ee6
6 changed files with 30 additions and 5 deletions
  1. 1 1
      app/components/home.tsx
  2. 1 0
      app/components/markdown.tsx
  3. 9 1
      app/locales/cn.ts
  4. 8 2
      app/locales/en.ts
  5. 8 1
      app/locales/tw.ts
  6. 3 0
      app/styles/markdown.scss

+ 1 - 1
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) ||

+ 1 - 0
app/components/markdown.tsx

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

+ 9 - 1
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} 发送`,
+    Input: (submitKey: string) => {
+      var inputHints = `输入消息,${submitKey} 发送`;
+      if (submitKey === String(SubmitKey.Enter)) {
+        inputHints += ", Shift + Enter 换行";
+      }
+      return inputHints;
+    },
     Send: "发送",
   },
   Export: {

+ 8 - 2
app/locales/en.ts

@@ -1,3 +1,4 @@
+import { SubmitKey } from "../store/app";
 import type { LocaleType } from "./index";
 
 const en: LocaleType = {
@@ -20,8 +21,13 @@ const en: LocaleType = {
       Retry: "Retry",
     },
     Typing: "Typing…",
-    Input: (submitKey: string) =>
-      `Type something and press ${submitKey} to send`,
+    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: {

+ 8 - 1
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} 鍵即可發送`,
+    Input: (submitKey: string) =>  {
+      var inputHints = `輸入訊息後,按下 ${submitKey} 鍵即可發送`;
+      if (submitKey === String(SubmitKey.Enter)) {
+        inputHints += ", Shift + Enter 鍵換行";
+      }
+      return inputHints;
+    },
     Send: "發送",
   },
   Export: {

+ 3 - 0
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;
+}