1
1
import * as React from 'react' ;
2
+ import type { Bookmark , EditorEvent , TinyMCE , Editor as TinyMCEEditor } from 'tinymce' ;
2
3
import { IEvents } from '../Events' ;
3
4
import { ScriptItem , ScriptLoader } from '../ScriptLoader2' ;
4
5
import { 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' ;
6
7
import { EditorPropTypes , IEditorPropTypes } from './EditorPropTypes' ;
7
- import type { Bookmark , Editor as TinyMCEEditor , EditorEvent , TinyMCE } from 'tinymce' ;
8
+
9
+ const changeEvents = 'change keyup compositionend setcontent CommentChange' ;
8
10
9
11
type OmitStringIndexSignature < T > = { [ K in keyof T as string extends K ? never : K ] : T [ K ] } ;
10
12
@@ -241,7 +243,7 @@ export class Editor extends React.Component<IAllProps> {
241
243
public componentWillUnmount ( ) {
242
244
const editor = this . editor ;
243
245
if ( editor ) {
244
- editor . off ( this . changeEvents ( ) , this . handleEditorChange ) ;
246
+ editor . off ( changeEvents , this . handleEditorChange ) ;
245
247
editor . off ( this . beforeInputEvent ( ) , this . handleBeforeInput ) ;
246
248
editor . off ( 'keypress' , this . handleEditorChangeSpecial ) ;
247
249
editor . off ( 'keydown' , this . handleBeforeInputSpecial ) ;
@@ -259,14 +261,6 @@ export class Editor extends React.Component<IAllProps> {
259
261
return this . inline ? this . renderInline ( ) : this . renderIframe ( ) ;
260
262
}
261
263
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
-
270
264
private beforeInputEvent ( ) {
271
265
return isBeforeInputEventAvailable ( ) ? 'beforeinput SelectionChange' : 'SelectionChange' ;
272
266
}
@@ -335,13 +329,13 @@ export class Editor extends React.Component<IAllProps> {
335
329
const wasControlled = isValueControlled ( prevProps ) ;
336
330
const nowControlled = isValueControlled ( this . props ) ;
337
331
if ( ! wasControlled && nowControlled ) {
338
- this . editor . on ( this . changeEvents ( ) , this . handleEditorChange ) ;
332
+ this . editor . on ( changeEvents , this . handleEditorChange ) ;
339
333
this . editor . on ( this . beforeInputEvent ( ) , this . handleBeforeInput ) ;
340
334
this . editor . on ( 'keydown' , this . handleBeforeInputSpecial ) ;
341
335
this . editor . on ( 'keyup' , this . handleEditorChangeSpecial ) ;
342
336
this . editor . on ( 'NewBlock' , this . handleEditorChange ) ;
343
337
} else if ( wasControlled && ! nowControlled ) {
344
- this . editor . off ( this . changeEvents ( ) , this . handleEditorChange ) ;
338
+ this . editor . off ( changeEvents , this . handleEditorChange ) ;
345
339
this . editor . off ( this . beforeInputEvent ( ) , this . handleBeforeInput ) ;
346
340
this . editor . off ( 'keydown' , this . handleBeforeInputSpecial ) ;
347
341
this . editor . off ( 'keyup' , this . handleEditorChangeSpecial ) ;
0 commit comments