Commit 360a5b28 by end

修改资讯

parent bf8b49da
No preview for this file type
......@@ -15,9 +15,9 @@ class Editor extends PureComponent {
constructor() {
super(...arguments);
this.state = {
editorState: "",
editorState: BraftEditor.createEditorState(''), // 初始化 editorState
defaultValue: "",
readOnly:false,
readOnly: false,
};
}
componentDidMount() {
......@@ -28,9 +28,8 @@ class Editor extends PureComponent {
})
}
if (importContent) {
console.log(importContent,type,'22222222222222222222')
this.setState({
defaultValue: BraftEditor.createEditorState(importContent),
editorState: BraftEditor.createEditorState(importContent), // 更新 editorState
});
}
......@@ -64,7 +63,7 @@ class Editor extends PureComponent {
};
render() {
const { uploadParam } = this.props;
const { editorState, defaultValue,readOnly } = this.state;
const { editorState, defaultValue, readOnly } = this.state;
const set = [
"undo",
"redo",
......@@ -316,8 +315,7 @@ class Editor extends PureComponent {
forceNewLine={false}
media={{ uploadFn: myUploadFn }}
className={styles.edit}
// value={editorState} //动态赋值会造成光标位移
value={defaultValue}
value={editorState} // 使用 editorState 作为 value
fontFamilies={fontFamilies}
fontSizes={fontSizes}
controls={set}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment