File tree 2 files changed +17
-12
lines changed
2 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -485,17 +485,16 @@ class Editor extends React.Component<EditorProps, EditorState> {
485
485
if ( this . state . text === value ) {
486
486
return ;
487
487
}
488
- this . setState (
489
- {
490
- text : value ,
491
- } ,
492
- ( ) => {
493
- emitter . emit ( emitter . EVENT_CHANGE , value , event , typeof event === 'undefined' ) ;
494
- if ( newSelection ) {
495
- setTimeout ( ( ) => this . setSelection ( newSelection ) ) ;
496
- }
497
- } ,
498
- ) ;
488
+ this . setState ( {
489
+ text : value ,
490
+ } ) ;
491
+ if ( this . props . onChange ) {
492
+ this . props . onChange ( { text, html : this . getHtmlValue ( ) } , event ) ;
493
+ }
494
+ emitter . emit ( emitter . EVENT_CHANGE , value , event , typeof event === 'undefined' ) ;
495
+ if ( newSelection ) {
496
+ setTimeout ( ( ) => this . setSelection ( newSelection ) ) ;
497
+ }
499
498
if ( ! this . hasContentChanged ) {
500
499
this . hasContentChanged = true ;
501
500
}
@@ -576,6 +575,12 @@ class Editor extends React.Component<EditorProps, EditorState> {
576
575
return emitter . EVENT_VIEW_CHANGE ;
577
576
case 'keydown' :
578
577
return emitter . EVENT_KEY_DOWN ;
578
+ case 'blur' :
579
+ return emitter . EVENT_BLUR ;
580
+ case 'focus' :
581
+ return emitter . EVENT_FOCUS ;
582
+ case 'scroll' :
583
+ return emitter . EVENT_SCROLL ;
579
584
}
580
585
}
581
586
/**
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import * as React from 'react';
2
2
3
3
export type UploadFunc = ( ( file : File ) => Promise < string > ) | ( ( file : File , callback : ( url : string ) => void ) => void ) ;
4
4
5
- export type EditorEvent = 'change' | 'fullscreen' | 'viewchange' | 'keydown' ;
5
+ export type EditorEvent = 'change' | 'fullscreen' | 'viewchange' | 'keydown' | 'focus' | 'blur' | 'scroll' ;
6
6
7
7
export interface EditorConfig {
8
8
theme ?: string ;
You can’t perform that action at this time.
0 commit comments