* The CKEditor component should not be updated by React itself. * However, if the component identifier changes, the whole structure should be created once again.
( nextProps: Readonly<Props<TEditor>> )
| 93 | * However, if the component identifier changes, the whole structure should be created once again. |
| 94 | */ |
| 95 | public override shouldComponentUpdate( nextProps: Readonly<Props<TEditor>> ): boolean { |
| 96 | const { props, editorSemaphore } = this; |
| 97 | |
| 98 | // Only when the component identifier changes the whole structure should be re-created once again. |
| 99 | if ( nextProps.id !== props.id ) { |
| 100 | return true; |
| 101 | } |
| 102 | |
| 103 | if ( nextProps.disableWatchdog !== props.disableWatchdog ) { |
| 104 | return true; |
| 105 | } |
| 106 | |
| 107 | if ( editorSemaphore ) { |
| 108 | editorSemaphore.runAfterMount( ( { instance } ) => { |
| 109 | if ( shouldUpdateEditorData( props, nextProps, instance ) ) { |
| 110 | instance.data.set( nextProps.data! ); |
| 111 | } |
| 112 | } ); |
| 113 | |
| 114 | if ( 'disabled' in nextProps ) { |
| 115 | editorSemaphore.runAfterMount( ( { instance } ) => { |
| 116 | if ( nextProps.disabled ) { |
| 117 | instance.enableReadOnlyMode( REACT_INTEGRATION_READ_ONLY_LOCK_ID ); |
| 118 | } else { |
| 119 | instance.disableReadOnlyMode( REACT_INTEGRATION_READ_ONLY_LOCK_ID ); |
| 120 | } |
| 121 | } ); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | return false; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Initialize the editor when the component is mounted. |
no test coverage detected