Added Ctrl-K keybind

This commit is contained in:
Adam Shea 2023-06-09 21:30:12 +00:00
parent 2a5c690bdc
commit 400f345182
No known key found for this signature in database
GPG key ID: 7CBE2859BC9F3090

View file

@ -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 });