]> Untitled Git - lemmy-ui.git/commitdiff
Add shortcut for submitting post (#1163)
authorSleeplessOne1917 <abias1122@gmail.com>
Mon, 12 Jun 2023 18:13:33 +0000 (18:13 +0000)
committerGitHub <noreply@github.com>
Mon, 12 Jun 2023 18:13:33 +0000 (14:13 -0400)
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
src/shared/components/common/markdown-textarea.tsx

index 7702d2bc98f33257e5c737d1847c18a04ec98887..b92170d839179ff9561ba46b9ded725ba67be5fc 100644 (file)
@@ -435,30 +435,45 @@ export class MarkdownTextArea extends Component<
   handleKeyBinds(i: MarkdownTextArea, event: KeyboardEvent) {
     if (event.ctrlKey) {
       switch (event.key) {
-        case "k":
+        case "k": {
           i.handleInsertLink(i, event);
           break;
-        case "b":
+        }
+        case "Enter": {
+          if (!this.isDisabled) {
+            i.handleSubmit(i, event);
+          }
+
+          break;
+        }
+        case "b": {
           i.handleInsertBold(i, event);
           break;
-        case "i":
+        }
+        case "i": {
           i.handleInsertItalic(i, event);
           break;
-        case "e":
+        }
+        case "e": {
           i.handleInsertCode(i, event);
           break;
-        case "8":
+        }
+        case "8": {
           i.handleInsertList(i, event);
           break;
-        case "s":
+        }
+        case "s": {
           i.handleInsertSpoiler(i, event);
           break;
-        case "p":
+        }
+        case "p": {
           if (i.state.content) i.handlePreviewToggle(i, event);
           break;
-        case ".":
+        }
+        case ".": {
           i.handleInsertQuote(i, event);
           break;
+        }
       }
     }
   }