Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keyboard shortcuts for markdown text editor #508

Conversation

rahulsnkr
Copy link
Contributor

Resolves #274 - Add the following keyboard shortcuts for the markdown text editor as mentioned in the issue

Ctrl-I - italics
Ctrl-B - bold
Ctrl-K - link
Ctrl-P - preformatted
Ctrl-Q - blockquote
Ctrl-U - upload an image

break;

case 75:
ev.preventDefault();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are only some of these using ev.preventDefault()? Do the others work without it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep that's right, specifically ev.preventDefault() is for Ctrl+P (opens the print dialog), Ctrl+K (focuses on the browser search bar), and Ctrl+U (opens the page source). The rest work without it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the other cases, is preventDefault() a no-op or does it not work (because there is no default)? If the former, I'm wondering if we should do it for all of them in case browsers add more overlapping key bindings in the future. Disclosure: this is not my area, so if this is a dumb question please let me know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, of course. I'm thinking of the default being "insert letter", but of course it's not if it's Ctrl. Thanks.

@ArtOfCode- ArtOfCode- merged commit 1061f7d into codidact:develop Jun 8, 2021
@rahulsnkr rahulsnkr deleted the rahulsnkr/274/markdown-keyboard-shortcuts branch August 13, 2021 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keyboard shortcuts within the post editor
3 participants