react-ckeditor-component-4
v1.0.1
Published
CKEditor 4 component for React
Downloads
95
Maintainers
Readme
ckeditor-react-component-4
React component for CKEditor 4
Installation
Usage
import CKEditor from "ckeditor-react-component-4";
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
ckeditor-react-component-4
is released under the MIT license
.