@@ -23,7 +23,6 @@ import RestoreButton from './RestoreButton'
23
23
import PermanentDeleteButton from './PermanentDeleteButton'
24
24
import InfoButton from './InfoButton'
25
25
import ToggleModeButton from './ToggleModeButton'
26
- import ToggleStackDirectionButton from './ToggleStackDirectionButton'
27
26
import InfoPanel from './InfoPanel'
28
27
import InfoPanelTrashed from './InfoPanelTrashed'
29
28
import { formatDate } from 'browser/lib/date-formatter'
@@ -60,13 +59,15 @@ class MarkdownNoteDetail extends React.Component {
60
59
this . toggleLockButton = this . handleToggleLockButton . bind ( this )
61
60
this . generateToc = this . handleGenerateToc . bind ( this )
62
61
this . handleUpdateContent = this . handleUpdateContent . bind ( this )
62
+ this . handleSwitchStackDirection = this . handleSwitchStackDirection . bind ( this )
63
63
}
64
64
65
65
focus ( ) {
66
66
this . refs . content . focus ( )
67
67
}
68
68
69
69
componentDidMount ( ) {
70
+ ee . on ( 'editor:orientation' , this . handleSwitchStackDirection )
70
71
ee . on ( 'topbar:togglelockbutton' , this . toggleLockButton )
71
72
ee . on ( 'topbar:toggledirectionbutton' , ( ) => this . handleSwitchDirection ( ) )
72
73
ee . on ( 'topbar:togglemodebutton' , ( ) => {
@@ -393,13 +394,16 @@ class MarkdownNoteDetail extends React.Component {
393
394
)
394
395
}
395
396
396
- handleSwitchStackDirection ( type ) {
397
- this . setState ( { isStacking : type } , ( ) => {
398
- this . focus ( )
399
- const newConfig = Object . assign ( { } , this . props . config )
400
- newConfig . ui . isStacking = type
401
- ConfigManager . set ( newConfig )
402
- } )
397
+ handleSwitchStackDirection ( ) {
398
+ this . setState (
399
+ prevState => ( { isStacking : ! prevState . isStacking } ) ,
400
+ ( ) => {
401
+ this . focus ( )
402
+ const newConfig = Object . assign ( { } , this . props . config )
403
+ newConfig . ui . isStacking = this . state . isStacking
404
+ ConfigManager . set ( newConfig )
405
+ }
406
+ )
403
407
}
404
408
405
409
handleSwitchDirection ( ) {
@@ -476,7 +480,7 @@ class MarkdownNoteDetail extends React.Component {
476
480
477
481
render ( ) {
478
482
const { data, dispatch, location, config } = this . props
479
- const { note, editorType, isStacking } = this . state
483
+ const { note, editorType } = this . state
480
484
const storageKey = note . storage
481
485
const folderKey = note . folder
482
486
@@ -553,12 +557,6 @@ class MarkdownNoteDetail extends React.Component {
553
557
/>
554
558
</ div >
555
559
< div styleName = 'info-right' >
556
- { editorType === 'SPLIT' ? (
557
- < ToggleStackDirectionButton
558
- onClick = { e => this . handleSwitchStackDirection ( e ) }
559
- isStacking = { isStacking }
560
- />
561
- ) : null }
562
560
< ToggleModeButton
563
561
onClick = { e => this . handleSwitchMode ( e ) }
564
562
editorType = { editorType }
0 commit comments