@@ -31,6 +31,7 @@ import { confirmDeleteNote } from 'browser/lib/confirmDeleteNote'
3131import markdownToc from 'browser/lib/markdown-toc-generator'
3232import queryString from 'query-string'
3333import { replace } from 'connected-react-router'
34+ import ToggleDirectionButton from 'browser/main/Detail/ToggleDirectionButton'
3435
3536class MarkdownNoteDetail extends React . Component {
3637 constructor ( props ) {
@@ -46,7 +47,8 @@ class MarkdownNoteDetail extends React.Component {
4647 isLockButtonShown : props . config . editor . type !== 'SPLIT' ,
4748 isLocked : false ,
4849 editorType : props . config . editor . type ,
49- switchPreview : props . config . editor . switchPreview
50+ switchPreview : props . config . editor . switchPreview ,
51+ RTL : false
5052 }
5153
5254 this . dispatchTimer = null
@@ -61,6 +63,7 @@ class MarkdownNoteDetail extends React.Component {
6163
6264 componentDidMount ( ) {
6365 ee . on ( 'topbar:togglelockbutton' , this . toggleLockButton )
66+ ee . on ( 'topbar:toggledirectionbutton' , ( ) => this . handleSwitchDirection ( ) )
6467 ee . on ( 'topbar:togglemodebutton' , ( ) => {
6568 const reversedType = this . state . editorType === 'SPLIT' ? 'EDITOR_PREVIEW' : 'SPLIT'
6669 this . handleSwitchMode ( reversedType )
@@ -99,6 +102,7 @@ class MarkdownNoteDetail extends React.Component {
99102
100103 componentWillUnmount ( ) {
101104 ee . off ( 'topbar:togglelockbutton' , this . toggleLockButton )
105+ ee . on ( 'topbar:toggledirectionbutton' , this . handleSwitchDirection )
102106 ee . off ( 'code:generate-toc' , this . generateToc )
103107 if ( this . saveQueue != null ) this . saveNow ( )
104108 }
@@ -354,6 +358,12 @@ class MarkdownNoteDetail extends React.Component {
354358 } )
355359 }
356360
361+ handleSwitchDirection ( ) {
362+ // If in split mode, hide the lock button
363+ const direction = this . state . RTL
364+ this . setState ( { RTL : ! direction } )
365+ }
366+
357367 handleDeleteNote ( ) {
358368 this . handleTrashButtonClick ( )
359369 }
@@ -393,6 +403,7 @@ class MarkdownNoteDetail extends React.Component {
393403 onChange = { this . handleUpdateContent . bind ( this ) }
394404 isLocked = { this . state . isLocked }
395405 ignorePreviewPointerEvents = { ignorePreviewPointerEvents }
406+ RTL = { this . state . RTL }
396407 />
397408 } else {
398409 return < MarkdownSplitEditor
@@ -404,6 +415,7 @@ class MarkdownNoteDetail extends React.Component {
404415 linesHighlighted = { note . linesHighlighted }
405416 onChange = { this . handleUpdateContent . bind ( this ) }
406417 ignorePreviewPointerEvents = { ignorePreviewPointerEvents }
418+ RTL = { this . state . RTL }
407419 />
408420 }
409421 }
@@ -472,7 +484,7 @@ class MarkdownNoteDetail extends React.Component {
472484 </ div >
473485 < div styleName = 'info-right' >
474486 < ToggleModeButton onClick = { ( e ) => this . handleSwitchMode ( e ) } editorType = { editorType } />
475-
487+ < ToggleDirectionButton onClick = { ( e ) => this . handleSwitchDirection ( e ) } isRTL = { this . state . RTL } />
476488 < StarButton
477489 onClick = { ( e ) => this . handleStarButtonClick ( e ) }
478490 isActive = { note . isStarred }
@@ -518,6 +530,7 @@ class MarkdownNoteDetail extends React.Component {
518530 print = { this . print }
519531 />
520532 </ div >
533+
521534 </ div >
522535
523536 return (
0 commit comments