* Creates an editor from the element and configuration. * * @param config CKEditor 5 editor configuration. * @returns Editor instance.
( config: EditorConfig )
| 320 | * @returns Editor instance. |
| 321 | */ |
| 322 | private async _createEditor( config: EditorConfig ): Promise<TEditor> { |
| 323 | const { editor: Editor } = this.props; |
| 324 | const supports = getInstalledCKBaseFeatures(); |
| 325 | |
| 326 | const mergedConfig = this._getMergedConfig( false, config ); |
| 327 | const editor = await ( |
| 328 | /* istanbul ignore next -- @preserve */ |
| 329 | supports.elementConfigAttachment ? |
| 330 | Editor.create( mergedConfig ) : |
| 331 | Editor.create( this.domContainer.current! as HTMLElement, mergedConfig ) |
| 332 | ); |
| 333 | |
| 334 | // Switch to the read-only mode if the `[disabled]` attribute is specified. |
| 335 | /* istanbul ignore else -- @preserve */ |
| 336 | if ( this.props.disabled ) { |
| 337 | editor.enableReadOnlyMode( REACT_INTEGRATION_READ_ONLY_LOCK_ID ); |
| 338 | } |
| 339 | |
| 340 | const modelDocument = editor.model.document; |
| 341 | const viewDocument = editor.editing.view.document; |
| 342 | |
| 343 | modelDocument.on( 'change:data', event => { |
| 344 | this.props.onChange?.( event, editor ); |
| 345 | } ); |
| 346 | |
| 347 | viewDocument.on( 'focus', event => { |
| 348 | this.props.onFocus?.( event, editor ); |
| 349 | } ); |
| 350 | |
| 351 | viewDocument.on( 'blur', event => { |
| 352 | this.props.onBlur?.( event, editor ); |
| 353 | } ); |
| 354 | |
| 355 | return editor; |
| 356 | } |
| 357 | |
| 358 | /** |
| 359 | * It gets an extended configuration containing the entries required for the integration configuration. |
no test coverage detected