11import * as React from 'react' ;
2+ import type { Bookmark , EditorEvent , TinyMCE , Editor as TinyMCEEditor } from 'tinymce' ;
23import { IEvents } from '../Events' ;
34import { ScriptItem , ScriptLoader } from '../ScriptLoader2' ;
45import { getTinymce } from '../TinyMCE' ;
5- import { isFunction , isTextareaOrInput , mergePlugins , uuid , configHandlers , isBeforeInputEventAvailable , isInDoc , setMode } from '../Utils' ;
6+ import { configHandlers , isBeforeInputEventAvailable , isFunction , isInDoc , isTextareaOrInput , mergePlugins , setMode , uuid } from '../Utils' ;
67import { EditorPropTypes , IEditorPropTypes } from './EditorPropTypes' ;
7- import type { Bookmark , Editor as TinyMCEEditor , EditorEvent , TinyMCE } from 'tinymce' ;
8+
9+ const changeEvents = 'change keyup compositionend setcontent CommentChange' ;
810
911type OmitStringIndexSignature < T > = { [ K in keyof T as string extends K ? never : K ] : T [ K ] } ;
1012
@@ -241,7 +243,7 @@ export class Editor extends React.Component<IAllProps> {
241243 public componentWillUnmount ( ) {
242244 const editor = this . editor ;
243245 if ( editor ) {
244- editor . off ( this . changeEvents ( ) , this . handleEditorChange ) ;
246+ editor . off ( changeEvents , this . handleEditorChange ) ;
245247 editor . off ( this . beforeInputEvent ( ) , this . handleBeforeInput ) ;
246248 editor . off ( 'keypress' , this . handleEditorChangeSpecial ) ;
247249 editor . off ( 'keydown' , this . handleBeforeInputSpecial ) ;
@@ -259,14 +261,6 @@ export class Editor extends React.Component<IAllProps> {
259261 return this . inline ? this . renderInline ( ) : this . renderIframe ( ) ;
260262 }
261263
262- private changeEvents ( ) {
263- const isIE = getTinymce ( this . view ) ?. Env ?. browser ?. isIE ( ) ;
264- return ( isIE
265- ? 'change keyup compositionend setcontent CommentChange'
266- : 'change input compositionend setcontent CommentChange'
267- ) ;
268- }
269-
270264 private beforeInputEvent ( ) {
271265 return isBeforeInputEventAvailable ( ) ? 'beforeinput SelectionChange' : 'SelectionChange' ;
272266 }
@@ -335,13 +329,13 @@ export class Editor extends React.Component<IAllProps> {
335329 const wasControlled = isValueControlled ( prevProps ) ;
336330 const nowControlled = isValueControlled ( this . props ) ;
337331 if ( ! wasControlled && nowControlled ) {
338- this . editor . on ( this . changeEvents ( ) , this . handleEditorChange ) ;
332+ this . editor . on ( changeEvents , this . handleEditorChange ) ;
339333 this . editor . on ( this . beforeInputEvent ( ) , this . handleBeforeInput ) ;
340334 this . editor . on ( 'keydown' , this . handleBeforeInputSpecial ) ;
341335 this . editor . on ( 'keyup' , this . handleEditorChangeSpecial ) ;
342336 this . editor . on ( 'NewBlock' , this . handleEditorChange ) ;
343337 } else if ( wasControlled && ! nowControlled ) {
344- this . editor . off ( this . changeEvents ( ) , this . handleEditorChange ) ;
338+ this . editor . off ( changeEvents , this . handleEditorChange ) ;
345339 this . editor . off ( this . beforeInputEvent ( ) , this . handleBeforeInput ) ;
346340 this . editor . off ( 'keydown' , this . handleBeforeInputSpecial ) ;
347341 this . editor . off ( 'keyup' , this . handleEditorChangeSpecial ) ;
0 commit comments