@@ -19,9 +19,9 @@ export default class CodeMirror extends React.Component {
1919
2020 this . editor = codemirror ( this . ref ) ;
2121
22- this . editor . on ( 'change' , ( ) => {
22+ this . editor . on ( 'change' , ( cm , metadata ) => {
2323 if ( this . props . onChange && this . initHydration ) {
24- this . props . onChange ( this . editor . getValue ( ) ) ;
24+ this . props . onChange ( cm , metadata , this . editor . getValue ( ) ) ;
2525 }
2626 } ) ;
2727
@@ -57,6 +57,42 @@ export default class CodeMirror extends React.Component {
5757 this . editor . on ( 'update' , this . props . onUpdate ) ;
5858 }
5959
60+ if ( this . props . onKeyDown ) {
61+ this . editor . on ( 'keydown' , ( cm , event ) => {
62+ this . props . onKeyDown ( cm , event ) ;
63+ } ) ;
64+ }
65+
66+ if ( this . props . onKeyUp ) {
67+ this . editor . on ( 'keyup' , ( cm , event ) => {
68+ this . props . onKeyUp ( cm , event ) ;
69+ } ) ;
70+ }
71+
72+ if ( this . props . onKeyPress ) {
73+ this . editor . on ( 'keypress' , ( cm , event ) => {
74+ this . props . onKeyPress ( cm , event ) ;
75+ } ) ;
76+ }
77+
78+ if ( this . props . onDragEnter ) {
79+ this . editor . on ( 'dragenter' , ( cm , event ) => {
80+ this . props . onDragEnter ( cm , event ) ;
81+ } ) ;
82+ }
83+
84+ if ( this . props . onDragOver ) {
85+ this . editor . on ( 'dragover' , ( cm , event ) => {
86+ this . props . onDragOver ( cm , event ) ;
87+ } ) ;
88+ }
89+
90+ if ( this . props . onDrop ) {
91+ this . editor . on ( 'drop' , ( cm , event ) => {
92+ this . props . onDrop ( cm , event ) ;
93+ } ) ;
94+ }
95+
6096 this . hydrate ( this . props ) ;
6197
6298 if ( this . props . editorDidMount ) {
0 commit comments