From 00979e92b7e6323f1297fe62fdf779379aa1b7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 30 Aug 2019 10:01:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=A7=BB=E5=8A=A8=E8=87=B3?= =?UTF-8?q?=20=E9=83=BD=E5=8A=A0=E4=B8=8A=E9=BB=98=E8=AE=A4=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/courses/Resource/index.js | 4 +- .../react/src/modules/courses/boards/index.js | 2 +- .../modules/courses/members/studentsList.js | 2 +- .../courses/shixunHomework/shixunHomework.js | 6 +- .../TPMUpdatepropaede/TPMUpdatepropaede.js | 134 +++--------------- 5 files changed, 23 insertions(+), 125 deletions(-) diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js index 8d9d3aa44..0e2cd7a86 100644 --- a/public/react/src/modules/courses/Resource/index.js +++ b/public/react/src/modules/courses/Resource/index.js @@ -838,7 +838,7 @@ class Fileslists extends Component{ {course_modules&&course_modules.course_modules.map((item,key)=>{ return( - filesId&&filesId===item.id?"":
  • this.moveTos(0)}>{item.module_name}
  • + filesId&&filesId===item.id?"":
  • this.moveTos(0)} title={item.module_name}>{item.module_name}
  • ) })} @@ -848,7 +848,7 @@ class Fileslists extends Component{ return (!this.state.dirSearchValue || item.name.indexOf(this.state.dirSearchValue) != -1) }).map((itm,k)=>{ return( - filesId&&filesId===itm.id?"":
  • this.moveTos(itm.id )}>{itm.name}
  • + filesId&&filesId===itm.id?"":
  • this.moveTos(itm.id )} title={itm.name}>{itm.name}
  • ) }) })} diff --git a/public/react/src/modules/courses/boards/index.js b/public/react/src/modules/courses/boards/index.js index dbb6dea1c..572c8dd63 100644 --- a/public/react/src/modules/courses/boards/index.js +++ b/public/react/src/modules/courses/boards/index.js @@ -387,7 +387,7 @@ class Boards extends Component{ boards && boards.filter((item)=> { return item.id != bid && (!this.state.dirSearchValue || item.name.indexOf(this.state.dirSearchValue) != -1) }).map( (item) => { - return
  • this.moveTo(item)}>{item.name}
  • + return
  • this.moveTo(item)} title={item.name}>{item.name}
  • }) } { isAdmin && diff --git a/public/react/src/modules/courses/members/studentsList.js b/public/react/src/modules/courses/members/studentsList.js index 096d19402..3726704cb 100644 --- a/public/react/src/modules/courses/members/studentsList.js +++ b/public/react/src/modules/courses/members/studentsList.js @@ -650,7 +650,7 @@ class studentsList extends Component{ return item.id != course_group_id && (!this.state.groupSearchValue || item.name.indexOf(this.state.groupSearchValue) != -1) }).map( item => { return ( -
  • this.moveToGroup(item)}>{item.name}
  • +
  • this.moveToGroup(item)} title={item.name}>{item.name}
  • ) }) } { isAdmin && diff --git a/public/react/src/modules/courses/shixunHomework/shixunHomework.js b/public/react/src/modules/courses/shixunHomework/shixunHomework.js index bf59380f5..dd5a93534 100644 --- a/public/react/src/modules/courses/shixunHomework/shixunHomework.js +++ b/public/react/src/modules/courses/shixunHomework/shixunHomework.js @@ -1100,7 +1100,7 @@ class ShixunHomework extends Component{ {course_modules&&course_modules.main_category.map((item,key)=>{ return( - datas&&datas.category_id===null?"":
  • this.moveTos(item.main_category_id)}>{item.main_category_name}
  • + datas&&datas.category_id===null?"":
  • this.moveTos(item.main_category_id)} title={item.main_category_name}>{item.main_category_name}
  • ) })} @@ -1109,10 +1109,10 @@ class ShixunHomework extends Component{ return (!this.state.dirSearchValue || item.category_name.indexOf(this.state.dirSearchValue) != -1) }).map( (item,key) => { if(datas&&datas.category_id!=null&&datas&&datas.category_id===item.category_id===false){ - return
  • this.moveTos(item.category_id )}>{item.category_name}
  • + return
  • this.moveTos(item.category_id )} title={item.category_name}>{item.category_name}
  • } if(datas&&datas.category_id===null){ - return
  • this.moveTos(item.category_id )}>{item.category_name}
  • + return
  • this.moveTos(item.category_id )} title={item.category_name}>{item.category_name}
  • } })} diff --git a/public/react/src/modules/tpm/TPMUpdatepropaede/TPMUpdatepropaede.js b/public/react/src/modules/tpm/TPMUpdatepropaede/TPMUpdatepropaede.js index 835debddb..a847c4125 100644 --- a/public/react/src/modules/tpm/TPMUpdatepropaede/TPMUpdatepropaede.js +++ b/public/react/src/modules/tpm/TPMUpdatepropaede/TPMUpdatepropaede.js @@ -4,139 +4,43 @@ import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal} from 'antd'; import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; -// import "antd/dist/antd.css"; - import axios from 'axios'; +import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; + import {getUrl} from 'educoder'; -let origin = getUrl(); - -let path = getUrl("/editormd/lib/") - -const $ = window.$; - -let timeout; - -let currentValue; - -const Option = Select.Option; - -const RadioGroup = Radio.Group; - -function create_editorMD(id, width, high, placeholder, imageUrl, callback) { - var editorName = window.editormd(id, { - width: width, - height: high, - path: path, // "/editormd/lib/" - - syncScrolling: "single", - tex: true, - tocm: true, - emoji: true, - taskList: true, - codeFold: true, - searchReplace: true, - htmlDecode: "style,script,iframe", - sequenceDiagram: true, - autoFocus: false, - toolbarIcons: function () { - // Or return editormd.toolbarModes[name]; // full, simple, mini - // Using "||" set icons align right. - return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"] - }, - toolbarCustomIcons: { - testIcon: "
    ", - testIcon1: "
    " - }, - //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 - saveHTMLToTextarea: true, - // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 - dialogMaskOpacity: 0.6, - placeholder: placeholder, - imageUpload: true, - imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], - imageUploadURL: imageUrl,//url - onload: function () { - // this.previewing(); - $("#" + id + " [type=\"latex\"]").bind("click", function () { - editorName.cm.replaceSelection("```latex"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("\n"); - editorName.cm.replaceSelection("```"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line - 1, 0); - }); - - $("#" + id + " [type=\"inline\"]").bind("click", function () { - editorName.cm.replaceSelection("$$$$"); - var __Cursor = editorName.cm.getDoc().getCursor(); - editorName.cm.setCursor(__Cursor.line, __Cursor.ch - 2); - editorName.cm.focus(); - }); - $("[type=\"inline\"]").attr("title", "行内公式"); - $("[type=\"latex\"]").attr("title", "多行公式"); - - window.md_elocalStorage(editorName, `UpdatepropaedeMDs_${id}`, "UpdatepropaedeMDs"); - - callback && callback() - } - }); - return editorName; -} export default class TPMUpdatepropaede extends Component { constructor(props) { super(props) + this.neweditanswerRef=React.createRef(); this.state = { - shixunId:undefined + shixunId:undefined, } } - updatepropaedeMD(initValue, id) { - - this.contentChanged = false; - const placeholder = ""; - // amp; - // 编辑时要传memoId - const imageUrl = `/api/attachments.json`; - // 创建editorMd - - const Updatepropaede_editormd = create_editorMD(id, '100%', 400, placeholder, imageUrl, () => { - setTimeout(() => { - Updatepropaede_editormd.resize() - Updatepropaede_editormd.cm && Updatepropaede_editormd.cm.refresh() - }, 500) - - if (initValue != undefined) { - Updatepropaede_editormd.setValue(initValue) - } - Updatepropaede_editormd.cm.on("change", (_cm, changeObj) => { - console.log('....contentChanged') - this.contentChanged = true; - }) - }); - this.Updatepropaede_editormd = Updatepropaede_editormd; - window.Updatepropaede_editormd = Updatepropaede_editormd; - } - componentDidMount() { let id = this.props.match.params.shixunId; let url="/shixuns/"+id+"/propaedeutics.json"; axios.get(url).then((response) => { - console.log(response) if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { }else{ this.setState({ - shixunId:id + shixunId:id, }) - if(response.data.content[0]!=null){ - this.updatepropaedeMD(response.data.content, "UpdatepropaedeMD"); + this.setState({ + editanswersRefval:response.data.content, + }) + this.neweditanswerRef.current.setValue(response.data.content) }else{ - this.updatepropaedeMD("", "UpdatepropaedeMD"); + this.setState({ + editanswersRefval:"", + }) + this.neweditanswerRef.current.setValue('') } } }).catch((error) => { @@ -148,7 +52,7 @@ export default class TPMUpdatepropaede extends Component { updatepropaedeuticsvalue=()=>{ let id = this.props.match.params.shixunId; let url="/shixuns/"+id+"/update_propaedeutics.json"; - const update_propaedeuticsvalue = this.Updatepropaede_editormd.getValue(); + const update_propaedeuticsvalue = this.editanswersRef.current.getValue().trim(); axios.post(url,{ content:update_propaedeuticsvalue } @@ -163,10 +67,7 @@ export default class TPMUpdatepropaede extends Component { }); } render() { - let {shixunId} = this.state; - - return (
    @@ -178,11 +79,8 @@ export default class TPMUpdatepropaede extends Component {
    -
    - -
    -
    -
    +