Commit 360a5b28 by end

修改资讯

parent bf8b49da
No preview for this file type
...@@ -15,9 +15,9 @@ class Editor extends PureComponent { ...@@ -15,9 +15,9 @@ class Editor extends PureComponent {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.state = { this.state = {
editorState: "", editorState: BraftEditor.createEditorState(''), // 初始化 editorState
defaultValue: "", defaultValue: "",
readOnly:false, readOnly: false,
}; };
} }
componentDidMount() { componentDidMount() {
...@@ -28,9 +28,8 @@ class Editor extends PureComponent { ...@@ -28,9 +28,8 @@ class Editor extends PureComponent {
}) })
} }
if (importContent) { if (importContent) {
console.log(importContent,type,'22222222222222222222')
this.setState({ this.setState({
defaultValue: BraftEditor.createEditorState(importContent), editorState: BraftEditor.createEditorState(importContent), // 更新 editorState
}); });
} }
...@@ -64,7 +63,7 @@ class Editor extends PureComponent { ...@@ -64,7 +63,7 @@ class Editor extends PureComponent {
}; };
render() { render() {
const { uploadParam } = this.props; const { uploadParam } = this.props;
const { editorState, defaultValue,readOnly } = this.state; const { editorState, defaultValue, readOnly } = this.state;
const set = [ const set = [
"undo", "undo",
"redo", "redo",
...@@ -316,8 +315,7 @@ class Editor extends PureComponent { ...@@ -316,8 +315,7 @@ class Editor extends PureComponent {
forceNewLine={false} forceNewLine={false}
media={{ uploadFn: myUploadFn }} media={{ uploadFn: myUploadFn }}
className={styles.edit} className={styles.edit}
// value={editorState} //动态赋值会造成光标位移 value={editorState} // 使用 editorState 作为 value
value={defaultValue}
fontFamilies={fontFamilies} fontFamilies={fontFamilies}
fontSizes={fontSizes} fontSizes={fontSizes}
controls={set} 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