@@ -42,9 +42,10 @@ class MarkdownNoteDetail extends React.Component {
42
42
content : '' ,
43
43
linesHighlighted : [ ]
44
44
} , props . note ) ,
45
- isLockButtonShown : false ,
45
+ isLockButtonShown : props . config . editor . type !== 'SPLIT' ,
46
46
isLocked : false ,
47
- editorType : props . config . editor . type
47
+ editorType : props . config . editor . type ,
48
+ switchPreview : props . config . editor . switchPreview
48
49
}
49
50
50
51
this . dispatchTimer = null
@@ -65,6 +66,9 @@ class MarkdownNoteDetail extends React.Component {
65
66
} )
66
67
ee . on ( 'hotkey:deletenote' , this . handleDeleteNote . bind ( this ) )
67
68
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 ( )
68
72
}
69
73
70
74
componentWillReceiveProps ( nextProps ) {
@@ -294,7 +298,7 @@ class MarkdownNoteDetail extends React.Component {
294
298
295
299
handleToggleLockButton ( event , noteStatus ) {
296
300
// first argument event is not used
297
- if ( this . props . config . editor . switchPreview === 'BLUR' && noteStatus === 'CODE' ) {
301
+ if ( noteStatus === 'CODE' ) {
298
302
this . setState ( { isLockButtonShown : true } )
299
303
} else {
300
304
this . setState ( { isLockButtonShown : false } )
@@ -320,7 +324,8 @@ class MarkdownNoteDetail extends React.Component {
320
324
}
321
325
322
326
handleSwitchMode ( type ) {
323
- this . setState ( { editorType : type } , ( ) => {
327
+ // If in split mode, hide the lock button
328
+ this . setState ( { editorType : type , isLockButtonShown : ! ( type === 'SPLIT' ) } , ( ) => {
324
329
this . focus ( )
325
330
const newConfig = Object . assign ( { } , this . props . config )
326
331
newConfig . editor . type = type
@@ -365,6 +370,7 @@ class MarkdownNoteDetail extends React.Component {
365
370
noteKey = { note . key }
366
371
linesHighlighted = { note . linesHighlighted }
367
372
onChange = { this . handleUpdateContent . bind ( this ) }
373
+ isLocked = { this . state . isLocked }
368
374
ignorePreviewPointerEvents = { ignorePreviewPointerEvents }
369
375
/>
370
376
} else {
0 commit comments