@@ -79,17 +79,22 @@ class MarkdownNoteDetail extends React.Component {
7979 ee . off ( 'topbar:togglelockbutton' , this . toggleLockButton )
8080 }
8181
82- handleChange ( e ) {
82+ handleUpdateTag ( ) {
8383 const { note } = this . state
84+ if ( this . refs . tags ) note . tags = this . refs . tags . value
85+ this . updateNote ( note )
86+ }
8487
88+ handleUpdateContent ( ) {
89+ const { note } = this . state
8590 note . content = this . refs . content . value
86- if ( this . refs . tags ) note . tags = this . refs . tags . value
8791 note . title = markdown . strip ( striptags ( findNoteTitle ( note . content ) ) )
88- note . updatedAt = new Date ( )
92+ this . updateNote ( note )
93+ }
8994
90- this . setState ( {
91- note
92- } , ( ) => {
95+ updateNote ( note ) {
96+ note . updatedAt = new Date ( )
97+ this . setState ( { note } , ( ) => {
9398 this . save ( )
9499 } )
95100 }
@@ -289,7 +294,7 @@ class MarkdownNoteDetail extends React.Component {
289294 config = { config }
290295 value = { note . content }
291296 storageKey = { note . storage }
292- onChange = { ( e ) => this . handleChange ( e ) }
297+ onChange = { this . handleUpdateContent . bind ( this ) }
293298 ignorePreviewPointerEvents = { ignorePreviewPointerEvents }
294299 />
295300 } else {
@@ -298,7 +303,7 @@ class MarkdownNoteDetail extends React.Component {
298303 config = { config }
299304 value = { note . content }
300305 storageKey = { note . storage }
301- onChange = { ( e ) => this . handleChange ( e ) }
306+ onChange = { this . handleUpdateContent . bind ( this ) }
302307 ignorePreviewPointerEvents = { ignorePreviewPointerEvents }
303308 />
304309 }
@@ -359,7 +364,7 @@ class MarkdownNoteDetail extends React.Component {
359364 < TagSelect
360365 ref = 'tags'
361366 value = { this . state . note . tags }
362- onChange = { ( e ) => this . handleChange ( e ) }
367+ onChange = { this . handleUpdateTag . bind ( this ) }
363368 />
364369
365370 < ToggleModeButton onClick = { ( e ) => this . handleSwitchMode ( e ) } editorType = { editorType } />
0 commit comments