Skip to content

Update the Editor Config based on the state  #132

@msrshahrukh100

Description

@msrshahrukh100

I want to update the config with respect to my state. But it seems like the editor component isn't updating even after the state change. Here is my CKEditor component ->

<CKEditor
    editor={ ClassicEditor }
    data={this.state.content}
    onInit={ editor => {
        console.log( 'Editor is ready to use!', editor );
    } }
    config={{
      simpleUpload: {
      uploadUrl: uploadUrl,
      headers: {
          'X-CSRFToken': csrftoken,
      }
    }}}
    onChange={ ( event, editor ) => {
        const data = editor.getData();
        this.setState({
          content: data
        })
        console.log( { event, editor, data } );
    } }
    onBlur={ ( event, editor ) => {
        console.log( 'Blur.', editor );
    } }
    onFocus={ ( event, editor ) => {
        console.log( 'Focus.', editor );
    } }
/>

I want to update the upload URL based on the state. It is stored in a variable like shown below -


const csrftoken = getCookie('csrftoken');
const uploadUrl = `https://example.com/api/blog/posts/images/${this.state.id}`

Ideally whenever i update the state the upload url should be appropriately changed. But this doesn't happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions