@@ -42,9 +42,10 @@ class MarkdownNoteDetail extends React.Component {
4242 content : '' ,
4343 linesHighlighted : [ ]
4444 } , props . note ) ,
45- isLockButtonShown : false ,
45+ isLockButtonShown : props . config . editor . type !== 'SPLIT' ,
4646 isLocked : false ,
47- editorType : props . config . editor . type
47+ editorType : props . config . editor . type ,
48+ switchPreview : props . config . editor . switchPreview
4849 }
4950
5051 this . dispatchTimer = null
@@ -65,6 +66,9 @@ class MarkdownNoteDetail extends React.Component {
6566 } )
6667 ee . on ( 'hotkey:deletenote' , this . handleDeleteNote . bind ( this ) )
6768 ee . on ( 'code:generate-toc' , this . generateToc )
69+
70+ // Focus content if using blur or double click
71+ if ( this . state . switchPreview === 'BLUR' || this . state . switchPreview === 'DBL_CLICK' ) this . focus ( )
6872 }
6973
7074 componentWillReceiveProps ( nextProps ) {
@@ -294,7 +298,7 @@ class MarkdownNoteDetail extends React.Component {
294298
295299 handleToggleLockButton ( event , noteStatus ) {
296300 // first argument event is not used
297- if ( this . props . config . editor . switchPreview === 'BLUR' && noteStatus === 'CODE' ) {
301+ if ( noteStatus === 'CODE' ) {
298302 this . setState ( { isLockButtonShown : true } )
299303 } else {
300304 this . setState ( { isLockButtonShown : false } )
@@ -320,7 +324,8 @@ class MarkdownNoteDetail extends React.Component {
320324 }
321325
322326 handleSwitchMode ( type ) {
323- this . setState ( { editorType : type } , ( ) => {
327+ // If in split mode, hide the lock button
328+ this . setState ( { editorType : type , isLockButtonShown : ! ( type === 'SPLIT' ) } , ( ) => {
324329 this . focus ( )
325330 const newConfig = Object . assign ( { } , this . props . config )
326331 newConfig . editor . type = type
@@ -365,6 +370,7 @@ class MarkdownNoteDetail extends React.Component {
365370 noteKey = { note . key }
366371 linesHighlighted = { note . linesHighlighted }
367372 onChange = { this . handleUpdateContent . bind ( this ) }
373+ isLocked = { this . state . isLocked }
368374 ignorePreviewPointerEvents = { ignorePreviewPointerEvents }
369375 />
370376 } else {
0 commit comments