Reactjs 在已初始化的draft.js编辑器中以编程方式设置文本

Reactjs 在已初始化的draft.js编辑器中以编程方式设置文本,reactjs,draftjs,Reactjs,Draftjs,这是我当前状态下的组件 class TextInput extends React.Component<TextInputProps, any> { constructor(props) { super(props); this.state = { editorState: EditorState.createWithContent(ContentState.createFromText(props.content))}; this.onChange =

这是我当前状态下的组件

class TextInput extends React.Component<TextInputProps, any> {
  constructor(props) {
    super(props);
    this.state = { editorState: EditorState.createWithContent(ContentState.createFromText(props.content))};
    this.onChange = this.onChange.bind(this);
  }

  onChange(editorState) {
    const { setContent } = this.props;
    this.setState({editorState});
    const plainText = editorState.getCurrentContent().getPlainText();
    setContent({ content: plainText });
  }
  render() {
    return (
      <TextEditor
        editorState={this.state.editorState}
        onChange={this.onChange}
      />
     );
  }
};
class TextInput扩展了React.Component{
建造师(道具){
超级(道具);
this.state={editorState:editorState.createWithContent(ContentState.createFromText(props.content))};
this.onChange=this.onChange.bind(this);
}
onChange(编辑状态){
const{setContent}=this.props;
this.setState({editorState});
常量明文=editorState.getCurrentContent().getPlainText();
setContent({content:plainText});
}
render(){
返回(
);
}
};
因此,基本上我在redux状态下保存编辑器的内容,而draft.js在组件内部管理其余内容。我想要的是能够设置编辑器的状态(仅纯文本内容),而不使用createWithContent。我在文档中找不到state.set或类似文件

replaceText是最接近的替代方案吗?()