@@ -6,21 +6,13 @@ import ModeIcon from 'boost/components/ModeIcon'
66import MarkdownPreview from 'boost/components/MarkdownPreview'
77import CodeEditor from 'boost/components/CodeEditor'
88import { IDLE_MODE , CREATE_MODE , EDIT_MODE , switchMode , switchArticle , switchFolder , clearSearch , updateArticle , destroyArticle , NEW } from 'boost/actions'
9- import aceModes from 'boost/ace-modes'
10- import Select from 'react-select'
119import linkState from 'boost/linkState'
1210import FolderMark from 'boost/components/FolderMark'
1311import TagLink from 'boost/components/TagLink'
1412import TagSelect from 'boost/components/TagSelect'
13+ import ModeSelect from 'boost/components/ModeSelect'
1514import activityRecord from 'boost/activityRecord'
1615
17- var modeOptions = aceModes . map ( function ( mode ) {
18- return {
19- label : mode ,
20- value : mode
21- }
22- } )
23-
2416function makeInstantArticle ( article ) {
2517 return Object . assign ( { } , article )
2618}
@@ -219,7 +211,16 @@ export default class ArticleDetail extends React.Component {
219211 handleModeChange ( value ) {
220212 let article = this . state . article
221213 article . mode = value
222- this . setState ( { article : article } )
214+ this . setState ( {
215+ article : article ,
216+ previewMode : false
217+ } )
218+ }
219+
220+ handleModeSelectBlur ( ) {
221+ if ( this . refs . code != null ) {
222+ this . refs . code . editor . focus ( )
223+ }
223224 }
224225
225226 handleContentChange ( e , value ) {
@@ -232,6 +233,14 @@ export default class ArticleDetail extends React.Component {
232233 this . setState ( { previewMode : ! this . state . previewMode } )
233234 }
234235
236+ handleTitleKeyDown ( e ) {
237+ console . log ( e . keyCode )
238+ if ( e . keyCode === 9 ) {
239+ e . preventDefault ( )
240+ this . refs . mode . handleIdleSelectClick ( )
241+ }
242+ }
243+
235244 renderEdit ( ) {
236245 let { folders } = this . props
237246
@@ -272,22 +281,21 @@ export default class ArticleDetail extends React.Component {
272281 < div className = 'detailPanel' >
273282 < div className = 'header' >
274283 < div className = 'title' >
275- < input placeholder = 'Title' ref = 'title' valueLink = { this . linkState ( 'article.title' ) } />
284+ < input onKeyDown = { e => this . handleTitleKeyDown ( e ) } placeholder = 'Title' ref = 'title' valueLink = { this . linkState ( 'article.title' ) } />
276285 </ div >
277- < Select
286+ < ModeSelect
278287 ref = 'mode'
279- onChange = { value => this . handleModeChange ( value ) }
280- clearable = { false }
281- options = { modeOptions }
282- placeholder = 'select mode...'
288+ onChange = { e => this . handleModeChange ( e ) }
283289 value = { this . state . article . mode }
284290 className = 'mode'
291+ onBlur = { ( ) => this . handleModeSelectBlur ( ) }
285292 />
286293 </ div >
287294
288295 { this . state . previewMode
289296 ? < MarkdownPreview content = { this . state . article . content } />
290297 : ( < CodeEditor
298+ ref = 'code'
291299 onChange = { ( e , value ) => this . handleContentChange ( e , value ) }
292300 readOnly = { false }
293301 mode = { this . state . article . mode }
0 commit comments