@@ -80,9 +80,7 @@ const configAttributes: Record<string, (v: string) => unknown> = {
8080const configRenames : Record < string , string > = { } ;
8181
8282// Function that checks if the disabled option is supported with the version used
83- const isDisabledOptionSupported = ( tinymce : TinyMCE ) : boolean => {
84- return ( ! TinyVer . isLessThan ( tinymce , '7.6.0' ) )
85- } ;
83+ const isDisabledOptionSupported = ( tinymce : TinyMCE ) : boolean => ! TinyVer . isLessThan ( tinymce , '7.6.0' ) ;
8684
8785class TinyMceEditor extends HTMLElement {
8886 private _status : Status ;
@@ -250,24 +248,26 @@ class TinyMceEditor extends HTMLElement {
250248 const baseConfig = this . _getConfig ( ) ;
251249 const conf : EditorOptions = {
252250 ...baseConfig ,
251+ ...{
252+ disabled : this . hasAttribute ( 'disabled' ) ,
253+ readonly : this . hasAttribute ( 'readonly' )
254+ } ,
253255 target,
254256 setup : ( editor : Editor ) => {
255257 this . _editor = editor ;
256- editor . on ( "init" , ( _e : unknown ) => {
257- const tinymce = this . _getTinymce ( ) ;
258- const isDisableSupported = isDisabledOptionSupported ( tinymce ) ;
259- if ( isDisableSupported && this . hasAttribute ( 'disabled' ) ) {
260- editor . options . set ( 'disabled' , true ) ;
261- }
262- if ( this . hasAttribute ( 'readonly' ) ) {
263- editor . options . set ( 'readonly' , true ) ;
264- }
258+ editor . on ( 'init' , ( _e : unknown ) => {
265259 this . _status = Status . Ready ;
266260 } ) ;
267261 editor . on ( 'SwitchMode' , ( _e : unknown ) => {
268262 // this assignment ensures the attribute is in sync with the editor
269263 this . readonly = this . readonly ;
270264 } ) ;
265+
266+ editor . on ( 'DisabledStateChange' , ( _e : unknown ) => {
267+ // this assignment ensures the attribute is in sync with the editor
268+ this . disabled = this . disabled ;
269+ } ) ;
270+
271271 Obj . each ( this . _eventHandlers , ( handler , event ) => {
272272 if ( handler !== undefined ) {
273273 editor . on ( event , handler ) ;
@@ -382,11 +382,11 @@ class TinyMceEditor extends HTMLElement {
382382 set disabled ( value : boolean ) {
383383 const tinymce = this . _getTinymce ?.( ) ;
384384 const isVersionNewer = tinymce ? isDisabledOptionSupported ( tinymce ) : true ;
385-
385+
386386 if ( this . _editor && this . _status === Status . Ready && isVersionNewer ) {
387- this . _editor . options . set ( 'disabled' , value ) ;
387+ this . _editor . options . set ( 'disabled' , value ) ;
388388 }
389-
389+
390390 if ( value && ! this . hasAttribute ( 'disabled' ) ) {
391391 this . setAttribute ( 'disabled' , '' ) ;
392392 } else if ( ! value && this . hasAttribute ( 'disabled' ) ) {
0 commit comments