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

added KeyBindings #103

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

added KeyBindings #103

wants to merge 8 commits into from

Conversation

mohan-mu
Copy link

@mohan-mu mohan-mu commented Mar 30, 2019

Hi Maintainers, I have added KeyBindings for the below keys

#71 ,#50
Ctrl-Alt-1 : Heading 1
Ctrl-Alt-2 : Heading 2
Ctrl-Alt-3 : Heading 3
Ctrl-Alt-4 : Heading 4
Ctrl-Alt-5 : Heading 5
Ctrl-Alt-6 : Heading 6
Shift-Ctrl-L : Links,
Shift-Ctrl-I : Image,
Shift-Ctrl-. : BlockQuote
Shift-Ctrl-':CodeBlock
Shift-U: Unordered list,
Shift-O :Ordered list,

Please check it out

Thank You

Copy link
Collaborator

@aero31aero aero31aero left a comment

Choose a reason for hiding this comment

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

Hey, I'm sorry for a late review on this.

I've pointed out two main issues I see with the current code and I think it'd be trivial to fix these.

Also, I think we can safely use the selectionChanger function for headings like:

cm.replaceSelection(
    selectionChanger(
        cm.getSelection(), '### ', ''
    )
);

Thanks for the changes @mohan-mu.

index.js Outdated
// bold
'Ctrl-B': function(cm) {
var selection = cm.getSelection();
cm.replaceSelection('**' + selection + '**');
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change takes away the existing functionality where you could use CTRL+B to toggle bold. This would always add more text. For example, pressing the hotkey twice on 'hello' would result in:

=> hello
=> **hello**
=> ****hello****

Arguably, the first approach wasn't foolproof either, but this implementation is immediately broken.

index.js Outdated
},
// keyboard shortcut
'Ctrl-L': function(cm) {
cm.replaceSelection(selectionChanger(cm.getSelection(), '<kbd>', '</kbd>'));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your changes appear to change the code to be indented with 2 characters instead of 4, which is the current convention of the file. I'd appreciate if you could make sure the file remains consistent.

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.

2 participants