-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Adds shortcuts #235
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
Adds shortcuts #235
Conversation
And also I added a shortcut to change from Editor to Preview by |
Greeeeeat!! Thank you for your supports! |
@@ -142,6 +142,12 @@ class MarkdownEditor extends React.Component { | |||
this.renderPreview(this.props.value) | |||
} | |||
|
|||
handleKeyDown(e) { | |||
if (this.state.status === 'CODE' && e.key == 'Escape') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the best shortcut is Ctrl + E
. In order to use it, multiple key is necessary (#227)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I often use Ctrl + E
in order to move cursor.... Considering it, I'm not sure it's the best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is Focus notes same as toggle main? Or is the escape from editing markdown? If the escape from editing makdown, I think esc is the best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's not same. Yes, escape from editing md. By default I set ESC
and I try to implement customizable key map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see😆 Great! We'll discuss it tomorrow!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, if vim keybind setting is added, ESC becomes duplicate..... Don't I have to care about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Ctrl + E
is best. And it may be better to make it customizable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ctrl + E is best.
I agree. I'm going to try to implement multiple key handler for shortcuts.
it may be better to make it customizable.
I think so. I'll try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thaaaaank you!!
Hi @asmsuechan san, |
@@ -8,6 +8,10 @@ class MarkdownEditor extends React.Component { | |||
constructor (props) { | |||
super(props) | |||
|
|||
this.hotkey = props.config.hotkey | |||
|
|||
this.keyPressed = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel keyPressed
should be at state
however I could not write smart code by using state. I want advice about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using state
better, too.
Simply, use state
for keeping state of the component :)
You can add state by writing blow.
this.state = {
// Other states...
keyPressed: []
}
If you want to update the state, use setState
method.
this.setState({
keyPressed: [a, b, c]
})
If you want to write smartly, you should use the logic of Redux. But now, we can't take advantage of Redux.
So, you don't need using logic of Redux.
@@ -244,6 +250,14 @@ class TopBar extends React.Component { | |||
}) | |||
} | |||
|
|||
handleFocusSearch () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not good name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it bad name!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, there is a method named handleSearchFocus()
... Thus it's a little confusing 😭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I missed it.
How about renaming existing handleSearchFocus
to handleOnSearchFocus
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handleOnSearchFocus
is good to me, thanks your suggestion!
@@ -138,6 +138,7 @@ class HotkeyTab extends React.Component { | |||
<li><code>Escape</code> (or <code>Esc</code> for short)</li> | |||
<li><code>VolumeUp</code>, <code>VolumeDown</code> and <code>VolumeMute</code></li> | |||
<li><code>MediaNextTrack</code>, <code>MediaPreviousTrack</code>, <code>MediaStop</code> and <code>MediaPlayPause</code></li> | |||
<li><code>Control</code> (or <code>Ctrl</code> for short)</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition, I added this.
@@ -287,6 +301,7 @@ class TopBar extends React.Component { | |||
onChange={(e) => this.handleSearchChange(e)} | |||
placeholder='Search' | |||
type='text' | |||
id='Search' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you add id
attribute?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I forgot to remove 😅
@@ -60,6 +60,13 @@ var file = { | |||
} | |||
}, | |||
{ | |||
label: 'Focus Note', | |||
accelerator: 'Control + E', | |||
click: function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can write below on ES2015+.
click() {
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I follow the code style in the same file. Should I change all of them to ES2015+ style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I want to change coding more modern!
} | ||
}, | ||
{ | ||
label: 'Prior Note', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think prev
is more famous. (But I'm not good at writing English. So if I was wrong, tell me please 🙇 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should fix it to prev
because the opposite word of next
seems previous
.
http://www.wordhippo.com/what-is/the-opposite-of/next.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, then let's fix to previous
!
Thank you for your information.
I fixed them 🙏 |
@@ -155,7 +155,7 @@ var view = { | |||
} | |||
}, | |||
{ | |||
label: 'Prior Note', | |||
label: 'Privious Note', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo 🐱
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG.....
} | ||
} | ||
|
||
handleKeyUp (e) { | ||
this.keyPressed[e.key] = false | ||
let newKeyPressed = this.state.keyPressed | ||
newKeyPressed[e.key] = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using Object.prototype.assign
is better way.
const keyPressed = Object.assign(this.state.keyPressed, {
[e.key]: false
})
this.setState({ keyPressed })
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know such an useful grammar! Thanks for your advise!
@@ -250,7 +250,7 @@ class TopBar extends React.Component { | |||
}) | |||
} | |||
|
|||
handleFocusSearch () { | |||
handleOnSearchFocus () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I changed to use |
{ | ||
label: 'Focus Search', | ||
accelerator: 'Control + S', | ||
click: function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, please write like below same as line 65 🙇
click () {
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG I left them 😨
I fixed forgotten legacy style. |
Thanks a lot! |
Hi, I added a shortcut to focus the note as
Ctrl + E
. Please feedback what you feel this shortcut.