Skip to content

Commit

Permalink
Merge pull request #508 from rahulsnkr/rahulsnkr/274/markdown-keyboar…
Browse files Browse the repository at this point in the history
…d-shortcuts

Add keyboard shortcuts for markdown text editor
  • Loading branch information
ArtOfCode- authored Jun 8, 2021
2 parents 3d50b55 + 80a522c commit 1061f7d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions app/assets/javascripts/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,39 @@ $(() => {
}
});

$('.js-post-field').on('keydown', ev => {
if (ev.ctrlKey) {
switch (ev.keyCode) {
case 66:
$('[data-action="bold"]').click();
break;

case 73:
$('[data-action="italic"]').click();
break;

case 75:
ev.preventDefault();
$('[data-modal="#markdown-link-insert"]').click();
break;

case 80:
ev.preventDefault();
$('[data-action="code"]').click();
break;

case 81:
$('[data-action="quote"]').click();
break;

case 85:
ev.preventDefault();
$('[data-modal="#markdown-image-upload"]').click();
break;
}
}
});

$(document).on('click', '.js-markdown-insert-link', ev => {
ev.preventDefault();

Expand Down

0 comments on commit 1061f7d

Please sign in to comment.