@@ -26,6 +26,8 @@ import TurndownService from 'turndown'
26
26
import {
27
27
gfm
28
28
} from 'turndown-plugin-gfm'
29
+ import { findStorage } from 'browser/lib/findStorage'
30
+ import { sendWakatimeHeartBeat } from 'browser/lib/wakatime-plugin'
29
31
30
32
CodeMirror . modeURL = '../node_modules/codemirror/mode/%N/%N.js'
31
33
@@ -741,8 +743,14 @@ export default class CodeEditor extends React.Component {
741
743
this . updateHighlight ( editor , changeObject )
742
744
743
745
this . value = editor . getValue ( )
746
+
747
+ const { storageKey, noteKey } = this . props
748
+ const storage = findStorage ( storageKey )
744
749
if ( this . props . onChange ) {
745
750
this . props . onChange ( editor )
751
+ if ( storage ) sendWakatimeHeartBeat ( storage . path , noteKey , storage . name , true , true , false )
752
+ } else {
753
+ if ( storage ) sendWakatimeHeartBeat ( storage . path , noteKey , storage . name , false , false , false )
746
754
}
747
755
}
748
756
@@ -846,6 +854,11 @@ export default class CodeEditor extends React.Component {
846
854
}
847
855
848
856
reload ( ) {
857
+ // wakatime
858
+ const { storageKey, noteKey } = this . props
859
+ const storage = findStorage ( storageKey )
860
+ if ( storage ) sendWakatimeHeartBeat ( storage . path , noteKey , storage . name , false , false , true )
861
+
849
862
// Change event shouldn't be fired when switch note
850
863
this . editor . off ( 'change' , this . changeHandler )
851
864
this . value = this . props . value
0 commit comments