diff --git a/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js b/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js index 2e6184428..11b88a037 100644 --- a/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js +++ b/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js @@ -132,6 +132,7 @@ function create_editorMD(id, width, high, placeholder, imageUrl, callback, initV // Or return editormd.toolbarModes[name]; // full, simple, mini // Using "||" set icons align right. const icons = ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "link", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"]; + // 试卷处用到的填空题新增按钮 if (__that.props.showNullButton) { icons.push('nullBtton') } @@ -228,12 +229,14 @@ export default class TPMMDEditor extends Component { const imageUrl = `/api/attachments.json`; // 创建editorMd let react_id = `react_${_id}`; + // 将实例存到了window window[react_id] = this const answers_editormd = create_editorMD(_id, '100%', this.props.height, _placeholder, imageUrl, (_editorName) => { const __editorName = _editorName; react_id = `react_${__editorName.id}`; const that = window[react_id] - + + // 一个延迟的recreate或resize,不加这段代码,md初始化可能会出现样式问题 setTimeout(() => { if (that.props.needRecreate == true) { __editorName.recreate() // 注意 必须在setValue之前触发,不然会清空 @@ -268,6 +271,7 @@ export default class TPMMDEditor extends Component { that.props.onCMBeforeChange(cm,change) }) that.answers_editormd = __editorName; + // 这里应该可以去掉了,方便调试加的 window[__editorName.id+'_'] = __editorName; }, initValue, this.onEditorChange,this.props.watch, { noStorage: this.props.noStorage, @@ -276,6 +280,7 @@ export default class TPMMDEditor extends Component { }, this); } + // 用在form里时,validate失败时出现一个红色边框 showError = () => { this.setState({showError: true}) }