我在我的React应用程序中使用CkEditor5来实现CKEditor。 我想根据我的状态更新配置,但在状态更改后似乎编辑器组件并没有更新。
这是我的CKEditor组件:
<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 );
} }
/>
我想根据状态更新上传的URL。它存储在变量中,如下所示 -
const csrftoken = getCookie('csrftoken');
const uploadUrl = `https://example.com/api/blog/posts/images/${this.state.id}`