codeslayer1 / react-ckeditor

CKEditor component for React with plugin and custom event listeners support
MIT License
129 stars 34 forks source link

How can I check that editor gets loaded ? #28

Closed anuraggautam77 closed 6 years ago

anuraggautam77 commented 6 years ago

I want setState to content but it shows me empty content in an editor after it gets loaded. This is due to delay in initialize the editor. How we can overcome this delay.

codeslayer1 commented 6 years ago

You can check for editor instanceReady event like this -

<CKEditor 
              events={{
                "instanceReady": this.onInstanceReady
              }}
             />

And then you can set content or do any other action in your onInstanceReady function.

anuraggautam77 commented 6 years ago

So still it's showing me blank.

<CKEditor ref='editor' activeClass="p10"   config={{language: 'en', toolbarCanCollapse: false}} 
  content={this.state.content}   placeholder="Trying ..." events={
                                      {  
                                           "blur": this.onBlur,
                                          "afterPaste": this.afterPaste,
                                          "change": this.onChange,
                                          "instanceReady": this.onInstanceReady
                            }}
                                      />

 onInstanceReady(){
 this.setState({
            content: data[0].bodyContent
        });
} 
anuraggautam77 commented 6 years ago

It works for me inside the instanceReady function.

evnt.editor.setData(json.posts[0].body);