mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-25 22:01:13 +00:00
Added additional keybinds
This commit is contained in:
parent
6227b63ad0
commit
cc64f71072
1 changed files with 25 additions and 4 deletions
|
@ -431,13 +431,34 @@ export class MarkdownTextArea extends Component<
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keybind handler
|
// Keybind handler
|
||||||
|
// Keybinds inspired by github comment area
|
||||||
handleKeyBinds(i: MarkdownTextArea, event: KeyboardEvent) {
|
handleKeyBinds(i: MarkdownTextArea, event: KeyboardEvent) {
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case "k": {
|
case "k": // Insert link
|
||||||
// Currently only one case but will support further keybinds
|
|
||||||
i.handleInsertLink(i, event);
|
i.handleInsertLink(i, event);
|
||||||
}
|
break;
|
||||||
|
case "b": // Insert bold
|
||||||
|
i.handleInsertBold(i, event);
|
||||||
|
break;
|
||||||
|
case "i": // Insert italic
|
||||||
|
i.handleInsertItalic(i, event);
|
||||||
|
break;
|
||||||
|
case "e": // Insert code
|
||||||
|
i.handleInsertCode(i, event);
|
||||||
|
break;
|
||||||
|
case "8": // Insert unordered list
|
||||||
|
i.handleInsertList(i, event);
|
||||||
|
break;
|
||||||
|
case "s": // Insert spoiler
|
||||||
|
i.handleInsertSpoiler(i, event);
|
||||||
|
break;
|
||||||
|
case "p": // Move to preview view
|
||||||
|
if (i.state.content) i.handlePreviewToggle(i, event);
|
||||||
|
break;
|
||||||
|
case ".": // Insert quote
|
||||||
|
i.handleInsertQuote(i, event);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -578,7 +599,7 @@ export class MarkdownTextArea extends Component<
|
||||||
|
|
||||||
handleInsertList(i: MarkdownTextArea, event: any) {
|
handleInsertList(i: MarkdownTextArea, event: any) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
i.simpleBeginningofLine("-");
|
i.simpleBeginningofLine(`-${i.getSelectedText() ? " " : ""}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleInsertQuote(i: MarkdownTextArea, event: any) {
|
handleInsertQuote(i: MarkdownTextArea, event: any) {
|
||||||
|
|
Loading…
Reference in a new issue