react-ckeditor-4
v4.11.1
Published
CKEditor component for React
Downloads
12
Maintainers
Readme
react-ckeditor-component
React component for CKEditor
Installation
Usage
import CKEditor from "react-ckeditor-component";
class Example extends Component {
constructor(props) {
super(props);
this.updateContent = this.updateContent.bind(this);
this.state = {
content: 'content',
}
}
updateContent(newContent) {
this.setState({
content: newContent
})
}
onChange(evt){
console.log("onChange fired with event info: ", evt);
var newContent = evt.editor.getData();
this.setState({
content: newContent
})
}
onBlur(evt){
console.log("onBlur event called with event info: ", evt);
}
afterPaste(evt){
console.log("afterPaste event called with event info: ", evt);
}
render() {
return (
<CKEditor
activeClass="p10"
content={this.state.content}
events={{
"blur": this.onBlur,
"afterPaste": this.afterPaste,
"change": this.onChange
}}
/>
)
}
}
The package also includes an in-built example under the /example
folder. Run the sample application by cloning project and running npm start.
Props
Note- Starting v1.0.6, you can listen to change
event directly by passing its event handler in events
prop instead of passing a separate onChange prop. The onChange prop is now deprecated.
License
react-ckeditor-component
is released under the MIT license
.