Commit 0e6356cc by wufan

Merge branch 'feature/yuananting/20210327/test-paper' into 'master'

fix:富文本创建重复

See merge request !17
parents 2f0d9525 166c3dca
......@@ -42,9 +42,16 @@ class QuestionEditor extends Component {
blanksList: props.blanksList || [],
};
}
componentDidMount() {
this.renderEditor();
const editorRoot = new E(
`#editor${this.state.editorId}_tabbar`,
`#editor${this.state.editorId}_content`
);
this.setState({ editorRoot }, () => {
this.renderEditor(editorRoot);
editorRoot.create();
this.editorRoot = editorRoot;
});
}
static getDerivedStateFromProps(nextProps, prevState) {
......@@ -57,7 +64,7 @@ class QuestionEditor extends Component {
const { detailInfo, blanksList } = nextProps;
if (this.state.detailInfo !== detailInfo) {
this.setState({ detailInfo: nextProps.detailInfo }, () => {
this.renderEditor();
this.renderEditor(this.state.editorRoot);
});
}
if (blanksList !== this.state.blanksList) {
......@@ -94,13 +101,9 @@ class QuestionEditor extends Component {
);
};
renderEditor() {
renderEditor(editorRoot) {
const { editorId, detailInfo } = this.state;
const { onChange, bindChangeContent } = this.props;
const editorRoot = new E(
`#editor${editorId}_tabbar`,
`#editor${editorId}_content`
);
editorRoot.config.menus = [];
editorRoot.config.uploadImgMaxSize = 1 * 1024 * 1024;
editorRoot.config.customAlert = function (info) {
......@@ -223,9 +226,6 @@ class QuestionEditor extends Component {
});
};
editorRoot.create();
this.editorRoot = editorRoot;
const contentHtml = /^\<p/.test(detailInfo.content)
? detailInfo.content
: `<p>${detailInfo.content}</p>`;
......
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