issues25489
hjm 5 years ago
parent 22948e1f5e
commit a1e96441fa

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

Loading…
Cancel
Save