Skip to content

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

Merged
merged 11 commits into from
Jan 21, 2017
Merged

Adds shortcuts #235

merged 11 commits into from
Jan 21, 2017

Conversation

asmsuechan
Copy link
Contributor

Hi, I added a shortcut to focus the note as Ctrl + E. Please feedback what you feel this shortcut.

2017-01-13 21 07 03

@asmsuechan
Copy link
Contributor Author

asmsuechan commented Jan 13, 2017

And also I added a shortcut to change from Editor to Preview by ESC.

@kazup01
Copy link
Member

kazup01 commented Jan 13, 2017

Greeeeeat!! Thank you for your supports!
We will check it tommorow👍

@@ -142,6 +142,12 @@ class MarkdownEditor extends React.Component {
this.renderPreview(this.props.value)
}

handleKeyDown(e) {
if (this.state.status === 'CODE' && e.key == 'Escape') {
Copy link
Contributor Author

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)

Copy link
Contributor Author

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.

Copy link
Member

@kazup01 kazup01 Jan 13, 2017

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.

Copy link
Contributor Author

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.

Copy link
Member

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!

Copy link
Contributor Author

@asmsuechan asmsuechan Jan 14, 2017

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?

Copy link
Member

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.

Copy link
Contributor Author

@asmsuechan asmsuechan Jan 14, 2017

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.

Copy link
Member

Choose a reason for hiding this comment

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

OK, thaaaaank you!!

@asmsuechan
Copy link
Contributor Author

asmsuechan commented Jan 13, 2017

And I also added a shortcut Focus Search(Ctrl + S) which toggles focus to search input. I'm not sure the name is proper or not.

2017-01-14 9 34 40

@asmsuechan asmsuechan changed the title Adds a shortcut which focuses the note Adds shortcuts Jan 14, 2017
@asmsuechan
Copy link
Contributor Author

asmsuechan commented Jan 14, 2017

And I also added shortcuts to move on to the next and prior note by Ctrl + U(up) and Ctrl + J(down). Actually I want to set Ctrl + K as up by default, however it's set as a default key map on edit mode by the OS (I'm using macOS).

I'm not sure what this setting is proper or not. Please feedback 🙏

2017-01-14 10 13 32

@kazup01
Copy link
Member

kazup01 commented Jan 14, 2017

Hi @asmsuechan san,
Since we'll update #215 today, we'll check your PRs after this!
Thank you for your cooperation!😘

@asmsuechan asmsuechan changed the title Adds shortcuts [WIP] Adds shortcuts Jan 14, 2017
@asmsuechan asmsuechan changed the title [WIP] Adds shortcuts Adds shortcuts Jan 14, 2017
@@ -8,6 +8,10 @@ class MarkdownEditor extends React.Component {
constructor (props) {
super(props)

this.hotkey = props.config.hotkey

this.keyPressed = []
Copy link
Contributor Author

@asmsuechan asmsuechan Jan 14, 2017

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.

Copy link
Contributor

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 () {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not good name

Copy link
Contributor

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!

Copy link
Contributor Author

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 😭

Copy link
Contributor

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?

Copy link
Contributor Author

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>
Copy link
Contributor Author

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'
Copy link
Contributor

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?

Copy link
Contributor Author

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 () {
Copy link
Contributor

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() {
}

Copy link
Contributor Author

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?

Copy link
Contributor

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',
Copy link
Contributor

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 🙇 )

Copy link
Contributor Author

@asmsuechan asmsuechan Jan 14, 2017

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

Copy link
Contributor

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.

@sota1235 sota1235 assigned asmsuechan and unassigned sota1235 Jan 17, 2017
@asmsuechan
Copy link
Contributor Author

I fixed them 🙏

@@ -155,7 +155,7 @@ var view = {
}
},
{
label: 'Prior Note',
label: 'Privious Note',
Copy link
Contributor

Choose a reason for hiding this comment

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

typo 🐱

Copy link
Contributor Author

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
Copy link
Contributor

@sota1235 sota1235 Jan 18, 2017

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 })

Copy link
Contributor Author

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 () {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@asmsuechan
Copy link
Contributor Author

I changed to use Object.assign and remove unnecessary lines.

{
label: 'Focus Search',
accelerator: 'Control + S',
click: function () {
Copy link
Contributor

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 () {
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OMG I left them 😨

@asmsuechan
Copy link
Contributor Author

I fixed forgotten legacy style.

@sota1235
Copy link
Contributor

Thanks a lot!

@sota1235 sota1235 merged commit 1672d9f into BoostIO:master Jan 21, 2017
@sota1235 sota1235 mentioned this pull request Jan 21, 2017
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.

3 participants