mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
add hotkey
This commit is contained in:
@@ -91,6 +91,11 @@ var BlueprintForm = React.createClass({
|
||||
PlanetActions.updateBlueprint(blueprintId, blueprint)
|
||||
}
|
||||
},
|
||||
handleKeyDown: function (e) {
|
||||
if (e.keyCode === 13 && e.metaKey) {
|
||||
this.submit()
|
||||
}
|
||||
},
|
||||
render: function () {
|
||||
var content = this.state.mode === BlueprintForm.EDIT_MODE ? (
|
||||
<div className='form-group'>
|
||||
@@ -104,7 +109,7 @@ var BlueprintForm = React.createClass({
|
||||
)
|
||||
|
||||
return (
|
||||
<div className='BlueprintForm'>
|
||||
<div onKeyDown={this.handleKeyDown} className='BlueprintForm'>
|
||||
<div className='modal-body'>
|
||||
<div className='form-group'>
|
||||
<input ref='title' className='block-input' valueLink={this.linkState('blueprint.title')} placeholder='Title'/>
|
||||
|
||||
@@ -40,13 +40,20 @@ var LaunchModal = React.createClass({
|
||||
this.setState({currentTab: 'blueprint'})
|
||||
},
|
||||
submit: function () {
|
||||
// this.props.submit('yolo')
|
||||
if (this.state.currentTab === 'snippet') {
|
||||
console.log(this.state.snippet)
|
||||
} else {
|
||||
console.log(this.state.blueprint)
|
||||
}
|
||||
},
|
||||
handleKeyDown: function (e) {
|
||||
if (e.keyCode === 37 && e.metaKey) {
|
||||
this.selectSnippetTab()
|
||||
}
|
||||
if (e.keyCode === 39 && e.metaKey) {
|
||||
this.selectBlueprintTab()
|
||||
}
|
||||
},
|
||||
render: function () {
|
||||
var modalBody
|
||||
if (this.state.currentTab === 'snippet') {
|
||||
@@ -60,7 +67,7 @@ var LaunchModal = React.createClass({
|
||||
}
|
||||
|
||||
return (
|
||||
<div onClick={this.stopPropagation} className='LaunchModal modal'>
|
||||
<div onKeyDown={this.handleKeyDown} onClick={this.stopPropagation} className='LaunchModal modal'>
|
||||
<div className='modal-header'>
|
||||
<div className='modal-tab'>
|
||||
<button className={this.state.currentTab === 'snippet' ? 'btn-primary active' : 'btn-default'} onClick={this.selectSnippetTab}>Snippet</button><button className={this.state.currentTab === 'blueprint' ? 'btn-primary active' : 'btn-default'} onClick={this.selectBlueprintTab}>Blueprint</button>
|
||||
|
||||
@@ -17,8 +17,19 @@ var PlanetNavigator = React.createClass({
|
||||
isLaunchModalOpen: false
|
||||
}
|
||||
},
|
||||
handleKeyDown: function (e) {
|
||||
if (e.keyCode === 13 && e.metaKey) {
|
||||
e.preventDefault()
|
||||
this.openLaunchModal()
|
||||
}
|
||||
},
|
||||
componentDidMount: function () {
|
||||
document.addEventListener('keydown', this.handleKeyDown, false)
|
||||
},
|
||||
componentWillUnmount: function () {
|
||||
document.removeEventListener('keydown', this.handleKeyDown, false)
|
||||
},
|
||||
openLaunchModal: function () {
|
||||
console.log('and...OPEN!!')
|
||||
this.setState({isLaunchModalOpen: true})
|
||||
},
|
||||
closeLaunchModal: function () {
|
||||
|
||||
@@ -83,9 +83,14 @@ var SnippetForm = React.createClass({
|
||||
PlanetActions.updateSnippet(snippetId, snippet)
|
||||
}
|
||||
},
|
||||
handleKeyDown: function (e) {
|
||||
if (e.keyCode === 13 && e.metaKey) {
|
||||
this.submit()
|
||||
}
|
||||
},
|
||||
render: function () {
|
||||
return (
|
||||
<div className='SnippetForm'>
|
||||
<div onKeyDown={this.handleKeyDown} className='SnippetForm'>
|
||||
<div className='modal-body'>
|
||||
<div className='form-group'>
|
||||
<textarea ref='description' className='snippetDescription block-input' valueLink={this.linkState('snippet.description')} placeholder='Description'/>
|
||||
|
||||
@@ -78,7 +78,7 @@ module.exports = React.createClass({
|
||||
|
||||
var index = this.getIndexOfCurrentArticle()
|
||||
|
||||
if (index < this.state.filteredArticles.length) {
|
||||
if (index < this.state.filteredArticles.length - 1) {
|
||||
this.selectArticleByIndex(index + 1)
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user