From: Adam Shea Date: Fri, 9 Jun 2023 21:30:12 +0000 (+0000) Subject: Added Ctrl-K keybind X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%7Bthis.state.thumbnail%7D?a=commitdiff_plain;h=400f345182caec6038df631a4392762d50b52944;p=lemmy-ui.git Added Ctrl-K keybind --- diff --git a/src/shared/components/common/markdown-textarea.tsx b/src/shared/components/common/markdown-textarea.tsx index eff10d7..efc812b 100644 --- a/src/shared/components/common/markdown-textarea.tsx +++ b/src/shared/components/common/markdown-textarea.tsx @@ -148,6 +148,7 @@ export class MarkdownTextArea extends Component< value={this.state.content} onInput={linkEvent(this, this.handleContentChange)} onPaste={linkEvent(this, this.handleImageUploadPaste)} + onKeyDown={linkEvent(this, this.handleKeyBinds)} required disabled={this.isDisabled} rows={2} @@ -429,6 +430,18 @@ export class MarkdownTextArea extends Component< i.contentChange(); } + // Keybind handler + handleKeyBinds(i: MarkdownTextArea, event: KeyboardEvent) { + if (event.ctrlKey) { + switch (event.key) { + case "k": { + // Currently only one case but will support further keybinds + i.handleInsertLink(i, event); + } + } + } + } + handlePreviewToggle(i: MarkdownTextArea, event: any) { event.preventDefault(); i.setState({ previewMode: !i.state.previewMode });