-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The CKEditor component fails to render while using @mui/material Button component #321
Comments
I have not found a reason for this, but presence of the button causes For a workaround, instead of an error the editor can be recursively initialized again by using |
Using conditional rendering allows rendering a button and an instance of CKEditor 5 next to each other. import React, { Component } from 'react';
import { Button } from "@mui/material";
import Editor from '@ckeditor/ckeditor5-build-classic';
import { CKEditor } from '@ckeditor/ckeditor5-react'
const EditorComponent = ( props ) => (
<CKEditor
editor={ Editor }
onReady={ editor => {
props.parent.setState( { showButton: true } );
window.editor = editor;
// You can store the "editor" and use when it is needed.
console.log( 'Editor is ready to use!', editor );
} }
onChange={ ( event, editor ) => {
const data = editor.getData();
console.log( { event, editor, data } );
} }
onBlur={ ( event, editor ) => {
console.log( 'Blur.', editor );
} }
onFocus={ ( event, editor ) => {
console.log( 'Focus.', editor );
} }
/>
);
class App extends Component {
constructor( ...all ) {
super( ...all );
this.state = {
showButton: false
}
}
render() {
return (
<div className="App">
<h2>Using CKEditor 5 from online builder in React</h2>
<EditorComponent parent={ this }/>
{ this.state.showButton ? <Button>Button</Button> : '' }
</div>
);
}
}
export default App; But still, this is a workaround rather than adequately fixing the issue. |
Also, it works fine with the previous version of the component ( |
Fix: Fixed the component initialization procedure to enforce cleanup completion before subsequent editor initialization. Closes #321. Closes #338. Thanks to @corymharper.
It seems that using a
<Button>
component from@mui/material
affects our component. After initializing the page, the<CKEditor />
component is destroyed.Required libraries:
Example code:
After running the page, only the button is visible.
The text was updated successfully, but these errors were encountered: