fix build bug

dev_aliyun2
harry 5 years ago
parent 66ca854680
commit 3aa620e58a

@ -75,9 +75,9 @@ module.exports = override(
// addWebpackPlugin(instance), // addWebpackPlugin(instance),
(config) => { (config) => {
config.resolve.plugins = config.resolve.plugins.filter(plugin => !(plugin instanceof ModuleScopePlugin)); config.resolve.plugins = config.resolve.plugins.filter(plugin => !(plugin instanceof ModuleScopePlugin));
if (process.env.NODE_ENV !== "development") { //if (process.env.NODE_ENV !== "development") {
config.output.publicPath = `/react/build/`; // config.output.publicPath = `/react/build/`;
} //}
return config return config
} }
); );

@ -3794,9 +3794,9 @@
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
}, },
"codemirror": { "codemirror": {
"version": "5.52.0", "version": "5.52.2",
"resolved": "https://registry.npm.taobao.org/codemirror/download/codemirror-5.52.0.tgz", "resolved": "https://registry.npm.taobao.org/codemirror/download/codemirror-5.52.2.tgz?cache=0&sync_timestamp=1584691606242&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcodemirror%2Fdownload%2Fcodemirror-5.52.2.tgz",
"integrity": "sha1-Tb1q738OY9uCa5ojki8MA6x1wKc=" "integrity": "sha1-wp4fcXn4XrDdF8BYb6gQ5IOP9YQ="
}, },
"collection-visit": { "collection-visit": {
"version": "1.0.0", "version": "1.0.0",
@ -5036,11 +5036,11 @@
} }
}, },
"echarts": { "echarts": {
"version": "4.6.0", "version": "4.7.0",
"resolved": "https://registry.npm.taobao.org/echarts/download/echarts-4.6.0.tgz", "resolved": "https://registry.npm.taobao.org/echarts/download/echarts-4.7.0.tgz",
"integrity": "sha1-taR6EEbOyTzu75VPnuVHUTQFWOw=", "integrity": "sha1-Wzh1pML5HjkpQl+rq56s5+QJiz8=",
"requires": { "requires": {
"zrender": "4.2.0" "zrender": "4.3.0"
} }
}, },
"editor.md": { "editor.md": {
@ -12317,9 +12317,9 @@
"integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=" "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc="
}, },
"qs": { "qs": {
"version": "6.9.1", "version": "6.9.2",
"resolved": "https://registry.npm.taobao.org/qs/download/qs-6.9.1.tgz", "resolved": "https://registry.npm.taobao.org/qs/download/qs-6.9.2.tgz?cache=0&sync_timestamp=1584892552959&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fqs%2Fdownload%2Fqs-6.9.2.tgz",
"integrity": "sha1-IAgsZct4IjY1qxqerKiHWim/jsk=" "integrity": "sha1-ontpUAZUSgS/DmxqfoEgd4km1b0="
}, },
"query-string": { "query-string": {
"version": "4.3.4", "version": "4.3.4",
@ -12899,9 +12899,9 @@
} }
}, },
"react": { "react": {
"version": "16.13.0", "version": "16.13.1",
"resolved": "https://registry.npm.taobao.org/react/download/react-16.13.0.tgz", "resolved": "https://registry.npm.taobao.org/react/download/react-16.13.1.tgz?cache=0&sync_timestamp=1584650109083&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Freact%2Fdownload%2Freact-16.13.1.tgz",
"integrity": "sha1-0EbqvN9k5Fe77tHnkuI14bmTTPc=", "integrity": "sha1-LoGIIvGpdDEiwGPWQQ2FweOv5I4=",
"requires": { "requires": {
"loose-envify": "^1.1.0", "loose-envify": "^1.1.0",
"object-assign": "^4.1.1", "object-assign": "^4.1.1",
@ -12974,9 +12974,9 @@
} }
}, },
"react-codemirror2": { "react-codemirror2": {
"version": "6.0.0", "version": "6.0.1",
"resolved": "https://registry.npm.taobao.org/react-codemirror2/download/react-codemirror2-6.0.0.tgz", "resolved": "https://registry.npm.taobao.org/react-codemirror2/download/react-codemirror2-6.0.1.tgz",
"integrity": "sha1-GABl31emQCYCbN5WmpcI/fdlZSU=" "integrity": "sha1-faukB5XrKlJjeSa2/gtzpukJByM="
}, },
"react-content-loader": { "react-content-loader": {
"version": "3.4.2", "version": "3.4.2",
@ -13222,14 +13222,14 @@
} }
}, },
"react-dom": { "react-dom": {
"version": "16.13.0", "version": "16.13.1",
"resolved": "https://registry.npm.taobao.org/react-dom/download/react-dom-16.13.0.tgz", "resolved": "https://registry.npm.taobao.org/react-dom/download/react-dom-16.13.1.tgz",
"integrity": "sha1-zd5UtI656KDKGz3JlD2btAm4GGY=", "integrity": "sha1-wb03MxoEhsB47lTEdAcgmTsuDn8=",
"requires": { "requires": {
"loose-envify": "^1.1.0", "loose-envify": "^1.1.0",
"object-assign": "^4.1.1", "object-assign": "^4.1.1",
"prop-types": "^15.6.2", "prop-types": "^15.6.2",
"scheduler": "^0.19.0" "scheduler": "^0.19.1"
} }
}, },
"react-error-overlay": { "react-error-overlay": {
@ -13985,9 +13985,9 @@
} }
}, },
"rsuite": { "rsuite": {
"version": "4.3.1", "version": "4.3.2",
"resolved": "https://registry.npm.taobao.org/rsuite/download/rsuite-4.3.1.tgz", "resolved": "https://registry.npm.taobao.org/rsuite/download/rsuite-4.3.2.tgz",
"integrity": "sha1-5e9YpDA7nB5jWXvi1eK/5zqeYUM=", "integrity": "sha1-tnakesqRBC3GqNc7+n/Gm+PMUY0=",
"requires": { "requires": {
"@babel/runtime": "^7.8.4", "@babel/runtime": "^7.8.4",
"classnames": ">=2.0.0", "classnames": ">=2.0.0",
@ -13999,15 +13999,15 @@
"react-lifecycles-compat": "^3.0.4", "react-lifecycles-compat": "^3.0.4",
"react-virtualized": "^9.21.0", "react-virtualized": "^9.21.0",
"recompose": "^0.30.0", "recompose": "^0.30.0",
"rsuite-table": "^3.9.3", "rsuite-table": "^3.9.4",
"rsuite-utils": "^2.2.1", "rsuite-utils": "^2.2.1",
"schema-typed": "^1.4.0" "schema-typed": "^1.4.0"
} }
}, },
"rsuite-table": { "rsuite-table": {
"version": "3.9.3", "version": "3.9.4",
"resolved": "https://registry.npm.taobao.org/rsuite-table/download/rsuite-table-3.9.3.tgz", "resolved": "https://registry.npm.taobao.org/rsuite-table/download/rsuite-table-3.9.4.tgz",
"integrity": "sha1-TEjh+ZqJy7C+9VOnTKI/2a91wBw=", "integrity": "sha1-PUiCfFmO8ZeF5KEkc29Vdj8Tnp0=",
"requires": { "requires": {
"@babel/runtime": "^7.8.4", "@babel/runtime": "^7.8.4",
"classnames": "^2.2.5", "classnames": "^2.2.5",
@ -14150,9 +14150,9 @@
} }
}, },
"scheduler": { "scheduler": {
"version": "0.19.0", "version": "0.19.1",
"resolved": "https://registry.npm.taobao.org/scheduler/download/scheduler-0.19.0.tgz", "resolved": "https://registry.npm.taobao.org/scheduler/download/scheduler-0.19.1.tgz",
"integrity": "sha1-pxXVYwLeQD33QvSpvhGXWzL1aY0=", "integrity": "sha1-Tz4u0sGn1laB9MhU+oxaHMtA8ZY=",
"requires": { "requires": {
"loose-envify": "^1.1.0", "loose-envify": "^1.1.0",
"object-assign": "^4.1.1" "object-assign": "^4.1.1"
@ -18292,9 +18292,9 @@
"integrity": "sha1-JGRSGW/KnlgfCavtm5DJSv9gFOI=" "integrity": "sha1-JGRSGW/KnlgfCavtm5DJSv9gFOI="
}, },
"zrender": { "zrender": {
"version": "4.2.0", "version": "4.3.0",
"resolved": "https://registry.npm.taobao.org/zrender/download/zrender-4.2.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fzrender%2Fdownload%2Fzrender-4.2.0.tgz", "resolved": "https://registry.npm.taobao.org/zrender/download/zrender-4.3.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fzrender%2Fdownload%2Fzrender-4.3.0.tgz",
"integrity": "sha1-0AEwLhVfKN4fn8f81cJUutKEcc8=" "integrity": "sha1-nwVhIbILuuREFNKHv2oRn/cEJmE="
} }
} }
} }

@ -11,8 +11,8 @@
"chalk": "1.1.3", "chalk": "1.1.3",
"classnames": "^2.2.5", "classnames": "^2.2.5",
"clipboard": "^2.0.4", "clipboard": "^2.0.4",
"codemirror": "^5.52.0", "codemirror": "^5.52.2",
"echarts": "^4.2.0-rc.2", "echarts": "^4.7.0",
"editor.md": "^1.5.0", "editor.md": "^1.5.0",
"flvplayer": "^1.1.5", "flvplayer": "^1.1.5",
"immutability-helper": "^3.0.1", "immutability-helper": "^3.0.1",
@ -28,16 +28,16 @@
"object-assign": "4.1.1", "object-assign": "4.1.1",
"promise": "8.0.1", "promise": "8.0.1",
"prop-types": "^15.6.1", "prop-types": "^15.6.1",
"qs": "^6.6.0", "qs": "^6.9.2",
"quill": "^1.3.7", "quill": "^1.3.7",
"quill-delta-to-html": "^0.11.0", "quill-delta-to-html": "^0.11.0",
"react": "^16.13.0", "react": "^16.13.1",
"react-beautiful-dnd": "^10.0.4", "react-beautiful-dnd": "^10.0.4",
"react-codemirror2": "^6.0.0", "react-codemirror2": "^6.0.1",
"react-content-loader": "^3.1.1", "react-content-loader": "^3.1.1",
"react-cookie": "^4.0.3", "react-cookie": "^4.0.3",
"react-cookies": "^0.1.1", "react-cookies": "^0.1.1",
"react-dom": "^16.13.0", "react-dom": "^16.13.1",
"react-infinite-scroller": "^1.2.4", "react-infinite-scroller": "^1.2.4",
"react-player": "^1.11.1", "react-player": "^1.11.1",
"react-redux": "5.0.7", "react-redux": "5.0.7",
@ -48,7 +48,7 @@
"react-url-query": "^1.4.0", "react-url-query": "^1.4.0",
"redux": "^4.0.0", "redux": "^4.0.0",
"redux-thunk": "^2.3.0", "redux-thunk": "^2.3.0",
"rsuite": "^4.0.1", "rsuite": "^4.3.2",
"scroll-into-view": "^1.12.3", "scroll-into-view": "^1.12.3",
"showdown": "^1.9.1", "showdown": "^1.9.1",
"showdown-katex": "^0.6.0", "showdown-katex": "^0.6.0",

@ -121,22 +121,9 @@ window._debugType = debugType;
export function initAxiosInterceptors(props) { export function initAxiosInterceptors(props) {
initOnlineOfflineListener() initOnlineOfflineListener()
// TODO 避免重复的请求 https://github.com/axios/axios#cancellation
// https://github.com/axios/axios/issues/1497
// TODO 读取到package.json中的配置
var proxy = "http://localhost:3000" var proxy = "http://localhost:3000"
// proxy = "http://testbdweb.trustie.net"
// proxy = "http://testbdweb.educoder.net"
// proxy = "https://testeduplus2.educoder.net"
//proxy="http://47.96.87.25:48080"
proxy = "https://pre-newweb.educoder.net" proxy = "https://pre-newweb.educoder.net"
proxy = "https://test-newweb.educoder.net" proxy = "https://test-newweb.educoder.net"
// proxy="https://test-jupyterweb.educoder.net"
// proxy="https://test-newweb.educoder.net"
// proxy="https://test-jupyterweb.educoder.net"
//proxy="https://test-jupyterweb.educoder.net/"
// 在这里使用requestMap控制避免用户通过双击等操作发出重复的请求 // 在这里使用requestMap控制避免用户通过双击等操作发出重复的请求
// 如果需要支持重复的请求考虑config里面自定义一个allowRepeat参考来控制 // 如果需要支持重复的请求考虑config里面自定义一个allowRepeat参考来控制
@ -212,10 +199,6 @@ export function initAxiosInterceptors(props) {
} }
const config = response.config const config = response.config
if (response.data.status === -1) { if (response.data.status === -1) {
// https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=cancel+request+in+response+interceptors+
// https://github.com/axios/axios/issues/583
// message.info(response.data.message || '服务端返回status -1请联系管理员。');
// props.showSnackbar( response.data.message || '服务器异常,请联系管理员。' )
if (window.location.pathname.startsWith('/tasks/')) { if (window.location.pathname.startsWith('/tasks/')) {
props.showSnackbar(response.data.message || '服务器异常,请联系管理员。') props.showSnackbar(response.data.message || '服务器异常,请联系管理员。')
} else { } else {

@ -33,14 +33,6 @@ export function getUrl(path) {
} }
export function getUrlmys(path, goTest) { export function getUrlmys(path, goTest) {
// https://www.educoder.net
// https://testbdweb.trustie.net
// 如果想所有url定位到测试版可以反注释掉下面这行
//goTest = true
// testbdweb.educoder.net testbdweb.trustie.net
// const local = goTest ? 'https://testeduplus2.educoder.net' : 'http://localhost:3000'
// const local = 'https://testeduplus2.educoder.net'
const local = 'https://test-jupyterweb.educoder.net' const local = 'https://test-jupyterweb.educoder.net'
if (isDev) { if (isDev) {
return `${local}${path ? path : ''}` return `${local}${path ? path : ''}`

@ -1,33 +1,12 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal} from 'antd'; import { getUrl, getUploadActionUrl } from 'educoder';
import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom";
// import "antd/dist/antd.css";
import { getImageUrl, toPath, getUrl,getUploadActionUrl } from 'educoder';
import axios from 'axios';
import "./makedown.css"; import "./makedown.css";
let origin = getUrl();
let path = getUrl("/editormd/lib/") let path = getUrl("/editormd/lib/")
const $ = window.$; const $ = window.$;
let timeout;
let currentValue;
const Option = Select.Option;
const RadioGroup = Radio.Group;
// 保存数据 // 保存数据
function md_add_data(k, mdu, d) { function md_add_data(k, mdu, d) {
window.sessionStorage.setItem(k + mdu, d); window.sessionStorage.setItem(k + mdu, d);
@ -49,8 +28,6 @@ function md_rec_data(k, mdu, id) {
if (window.sessionStorage.getItem(k + mdu) !== null) { if (window.sessionStorage.getItem(k + mdu) !== null) {
var editor = $("#e_tips_" + id).data('editor'); var editor = $("#e_tips_" + id).data('editor');
editor.setValue(window.sessionStorage.getItem(k + mdu)); editor.setValue(window.sessionStorage.getItem(k + mdu));
// debugger;
// /shixuns/b5hjq9zm/challenges/3977/tab=3 setValue可能导致editor样式问题
md_clear_data(k, mdu, id); md_clear_data(k, mdu, id);
} }
} }

@ -1,21 +1,12 @@
import React, { Component } from "react"; import React, { Component } from "react";
import { import { InputNumber, Checkbox, } from 'antd';
Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip
} from 'antd';
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
import axios from 'axios' import axios from 'axios'
import update from 'immutability-helper' import update from 'immutability-helper'
import { qNameArray } from './common' import { qNameArray } from './common'
import NullMDEditor from './NullMDEditor' import NullMDEditor from './NullMDEditor'
import NullChildEditor from './NullChildEditor' import NullChildEditor from './NullChildEditor'
import {getUrl, ActionBtn, DMDEditor} from 'educoder'; import { ActionBtn } from 'educoder';
const { TextArea } = Input;
const confirm = Modal.confirm;
const $ = window.$
const { Option } = Select;
class NullEditor extends Component { class NullEditor extends Component {
constructor(props) { constructor(props) {
@ -106,22 +97,6 @@ class NullEditor extends Component{
} }
/**
{
"question_title":"社会主义核心价值观(),(),()...",
"question_type":3,
"question_score":5,
"standard_answers":[
{"choice_id":1,
"answer_text":["abbc","xxx","sssss"]
},
{"choice_id":2,
"answer_text":["abbc","xxx","sssss"]
}
]
"is_ordered":true
}
}*/
const Id = this.props.match.params.Id const Id = this.props.match.params.Id
if (question_id) { if (question_id) {
const editUrl = this.props.getEditQuestionUrl(question_id); const editUrl = this.props.getEditQuestionUrl(question_id);
@ -222,7 +197,8 @@ class NullEditor extends Component{
this.setState( this.setState(
(prevState) => ({ (prevState) => ({
standard_answers: update(prevState.standard_answers, standard_answers: update(prevState.standard_answers,
{[index]: {
[index]:
{ $splice: [[childIndex, 1]] } { $splice: [[childIndex, 1]] }
} }
) )
@ -236,7 +212,8 @@ class NullEditor extends Component{
this.setState( this.setState(
(prevState) => ({ (prevState) => ({
standard_answers: update(prevState.standard_answers, standard_answers: update(prevState.standard_answers,
{[index]: {
[index]:
{ $splice: [[childIndex, 1]] } { $splice: [[childIndex, 1]] }
} }
) )
@ -263,16 +240,9 @@ class NullEditor extends Component{
let { question_title, question_score, question_type, question_choices, standard_answers let { question_title, question_score, question_type, question_choices, standard_answers
, is_ordered } = this.state; , is_ordered } = this.state;
let { question_id, index, exerciseIsPublish, let { question_id, index, exerciseIsPublish,
// question_title,
// question_type,
// question_score,
isNew } = this.props; isNew } = this.props;
// const { getFieldDecorator } = this.props.form;
const isAdmin = this.props.isAdmin()
const courseId=this.props.match.params.coursesId;
const isEdit = !!this.props.question_id
const qNumber = `question_${index}`; const qNumber = `question_${index}`;
// console.log(this.state.showtype) // console.log(this.state.showtype)
@ -322,13 +292,6 @@ class NullEditor extends Component{
addChildAnswer={this.addChildAnswer} addChildAnswer={this.addChildAnswer}
deleteChildAnswer={this.deleteChildAnswer} deleteChildAnswer={this.deleteChildAnswer}
></NullChildEditor> ></NullChildEditor>
// answer.map((item, itemIndex) => {
// return <DMDEditor
// toMDMode={this.toMDMode} noStorage={true}
// mdID={`answer_${index}${itemIndex}`} placeholder="请您输入题目" height={155} watch={false}
// initValue={item} onChange={(val) => this.onAnswerChange(index, itemIndex, val)}
// ></DMDEditor>
// })
}) })
} }
@ -360,5 +323,4 @@ class NullEditor extends Component{
) )
} }
} }
// RouteHOC() export default NullEditor;
export default (NullEditor);

@ -1,317 +0,0 @@
import React, { Component } from 'react'
import { getUploadActionUrl, getUrl } from 'educoder';
let path = getUrl("/editormd/lib/")
const $ = window.$;
// 保存数据
function md_add_data(k, mdu, d) {
window.sessionStorage.setItem(k + mdu, d);
}
// 清空保存的数据
function md_clear_data(k, mdu, id) {
window.sessionStorage.removeItem(k + mdu);
var id1 = "#e_tip_" + id;
var id2 = "#e_tips_" + id;
if (k == 'content') {
$(id2).html(" ");
} else {
$(id1).html(" ");
}
}
window.md_clear_data = md_clear_data
// editor 存在了jquery对象上应用不需要自己写md_rec_data方法了
function md_rec_data(k, mdu, id) {
if (window.sessionStorage.getItem(k + mdu) !== null) {
var editor = $("#e_tips_" + id).data('editor');
editor.setValue(window.sessionStorage.getItem(k + mdu));
// debugger;
// /shixuns/b5hjq9zm/challenges/3977/tab=3 setValue可能导致editor样式问题
md_clear_data(k, mdu, id);
}
}
window.md_rec_data = md_rec_data;
function md_elocalStorage(editor, mdu, id) {
if (window.sessionStorage) {
var oc = window.sessionStorage.getItem('content' + mdu);
if (oc !== null) {
console.log("#e_tips_" + id)
$("#e_tips_" + id).data('editor', editor);
var h = '您上次有已保存的数据,是否<a style="cursor: pointer;" class="link-color-blue" onclick="md_rec_data(\'content\',\'' + mdu + '\',\'' + id + '\')">恢复</a> ? / <a style="cursor: pointer;" class="link-color-blue" onclick="md_clear_data(\'content\',\'' + mdu + '\',\'' + id + '\')">不恢复</a>';
$("#e_tips_" + id).html(h);
}
setInterval(function () {
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();
h = h < 10 ? '0' + h : h;
m = m < 10 ? '0' + m : m;
s = s < 10 ? '0' + s : s;
if (editor.getValue().trim() != "") {
md_add_data("content", mdu, editor.getValue());
var id1 = "#e_tip_" + id;
var id2 = "#e_tips_" + id;
var textStart = " 数据已于 "
var text = textStart + h + ':' + m + ':' + s + " 保存 ";
// 占位符
var oldHtml = $(id2).html();
if (oldHtml && oldHtml != ' ' && oldHtml.startsWith(textStart) == false) {
$(id2).html(oldHtml.split(' (')[0] + ` (${text})`);
} else {
$(id2).html(text);
}
// $(id2).html("");
}
}, 10000);
} else {
$("#e_tip_" + id).after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!');
}
}
function create_editorMD(id, width, high, placeholder, imageUrl, callback, initValue,
onchange, watch, { noStorage, showNullButton }, that) {
// 还是出现了setting只有一份被共用的问题
var editorName = window.editormd(id, {
width: width,
height: high === undefined ? 400 : high,
path: path, // "/editormd/lib/"
markdown: initValue,
dialogLockScreen: false,
watch: watch === undefined ? true : watch,
syncScrolling: "single",
tex: true,
tocm: true,
emoji: true,
taskList: true,
codeFold: true,
searchReplace: true,
htmlDecode: "style,script,iframe",
sequenceDiagram: true,
autoFocus: false,
// mine
toolbarIcons: function (mdEditor) {
//
// let react_id = `react_${id}`;
// const __that = window[react_id]
// Or return editormd.toolbarModes[name]; // full, simple, mini
// Using "||" set icons align right.
const icons = ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"];
// if (__that.props.showNullButton) {
// icons.push('nullBtton')
// }
return icons
},
toolbarCustomIcons: {
testIcon: "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
testIcon1: "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>",
nullBtton: "<a type=\"nullBtton\" class='pr' title='增加填空'><div class='border-left'><span></span></div><span class='fillTip'>点击插入填空项</span><i class=\"iconfont icon-edit font-16\"></i></a>",
},
//这个配置在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
onchange: onchange,
onload: function () {
let _id = this.id // 如果要使用this这里不能使用箭头函数
let _editorName = this;
let react_id = `react_${_editorName.id}`;
const __that = window[react_id]
// this.previewing();
// let _id = id;
$("#" + _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 - 3);
_editorName.cm.focus();
});
$("[type=\"inline\"]").attr("title", "行内公式");
$("[type=\"latex\"]").attr("title", "多行公式");
if (__that.props.showNullButton) {
const NULL_CH = '▁'
// const NULL_CH = ''
// const NULL_CH = '🈳'
$("#" + _id + " [type=\"nullBtton\"]").bind("click", function () {
_editorName.cm.replaceSelection(NULL_CH);
// var __Cursor = _editorName.cm.getDoc().getCursor();
// _editorName.cm.setCursor(__Cursor.line - 1, 0);
});
}
if (noStorage == true) {
} else {
md_elocalStorage(_editorName, `MDEditor__${_id}`, _id);
}
callback && callback(_editorName)
}
});
return editorName;
}
export default class MDEditors extends Component {
constructor(props) {
super(props)
this.state = {
initValue: ''
}
}
componentDidUpdate(prevProps, prevState) {
// 不能加,影响了试卷填空题
// if (this.props.initValue != prevProps.initValue) {
// this.answers_editormd.setValue(this.props.initValue)
// }
}
// react_mdEditor_
componentDidMount = () => {
const { mdID, initValue, placeholder, showNullButton } = this.props;
let _id = `mdEditor_${mdID}`
this.contentChanged = false;
const _placeholder = placeholder || "";
// amp;
// 编辑时要传memoId
const imageUrl = `${getUploadActionUrl()}`;
// 创建editorMd
let react_id = `react_${_id}`;
window[react_id] = this
const answers_editormd = create_editorMD(_id, '100%', this.props.height, _placeholder, imageUrl, (__editorName) => {
react_id = `react_${__editorName.id}`;
const that = window[react_id]
setTimeout(() => {
console.log('timeout', __editorName.id)
__editorName.resize()
__editorName.cm && __editorName.cm.refresh()
}, that.props.refreshTimeout || 500)
if (that.props.initValue != undefined && that.props.initValue != '') {
__editorName.setValue(that.props.initValue)
}
if (that.state.initValue) {
__editorName.setValue(that.state.initValue)
}
__editorName.cm.on("change", (_cm, changeObj) => {
that.contentChanged = true;
if (that.state.showError) {
that.setState({ showError: false })
}
that.onEditorChange()
})
that.props.onCMBlur && __editorName.cm.on('blur', () => {
that.props.onCMBlur()
})
that.props.onCMBeforeChange && __editorName.cm.on('beforeChange', (cm, change) => {
that.props.onCMBeforeChange(cm, change)
})
that.answers_editormd = __editorName;
window[_id] = __editorName;
}, initValue, this.onEditorChange, this.props.watch, {
noStorage: this.props.noStorage,
showNullButton: this.props.showNullButton
}, this);
}
showError = () => {
this.setState({ showError: true })
}
onEditorChange = () => {
this.props.setcheckoutcontent()
if (!this.answers_editormd) return;
const val = this.answers_editormd.getValue();
try {
this.props.onChange && this.props.onChange(val)
} catch (e) {
// http://localhost:3007/courses/1309/common_homeworks/6566/setting
// 从这个页面,跳转到编辑页面,再在编辑页面点击返回的时候,这里会报错
console.error('出错')
console.error(e)
}
}
resize = () => {
if (!this.answers_editormd) { // 还未初始化
return;
}
this.answers_editormd.resize()
this.answers_editormd.cm && this.answers_editormd.cm.refresh()
this.answers_editormd.cm.focus()
}
getValue = () => {
try {
return this.answers_editormd.getValue()
} catch (e) {
return ''
}
}
setValue = (val) => {
try {
this.answers_editormd.setValue(val)
} catch (e) {
// TODO 这里多实例的时候前一个实例的state会被后面这个覆盖 参考NewWork.js http://localhost:3007/courses/1309/homework/9300/edit/1
// 未初始化
this.setState({ initValue: val })
}
}
render() {
let {
showError
} = this.state;
let { mdID, className, noStorage } = this.props;
let _style = {}
if (showError) {
_style.border = '1px solid red'
}
return (
<React.Fragment>
<div className={`df ${className} mt20`} >
{/* padding10-20 */}
<div className="edu-back-greyf5 radius4" id={`mdEditor_${mdID}`} style={{ ..._style }}>
<textarea style={{ display: 'none' }} id="evaluate_script_show" name="content" ></textarea>
<div className="CodeMirror cm-s-defualt">
</div>
</div>
</div>
<div className={"fr rememberTip"}>
{noStorage == true ? ' ' : <p id={`e_tips_mdEditor_${mdID}`} className="edu-txt-right color-grey-cd font-12"> </p>}
{/* {noStorage == true ? ' ' : <p id={`e_tips_mdEditor_${mdID}`} className="edu-txt-right color-grey-cd font-12"> </p>} */}
</div>
</React.Fragment>
)
}
}

@ -1,11 +1,10 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import axios from 'axios'; import axios from 'axios';
import { Input, Spin, Icon, Button, Pagination, DatePicker } from 'antd'; import { Input, Spin, Button, DatePicker } from 'antd';
import { handleDateString, getUrl, setmiyah } from 'educoder'; import { handleDateString, getUrl, setmiyah } from 'educoder';
import locale from 'antd/lib/date-picker/locale/zh_CN';
import MDEditors from '../MDEditors';
import moment from 'moment'; import moment from 'moment';
import '../packageconcnet.css'; import '../packageconcnet.css';
import MDEditors from '../../tpm/challengesnew/TPMMDEditor';
const { Search } = Input; const { Search } = Input;
const $ = window.$; const $ = window.$;
let origin = getUrl(); let origin = getUrl();

@ -5,9 +5,6 @@ import '../../courses/css/Courses.css'
import './css/TPMchallengesnew.css'; import './css/TPMchallengesnew.css';
require('codemirror/lib/codemirror.css'); require('codemirror/lib/codemirror.css');
let path = '/editormd/lib/'
path = getUrl("/editormd/lib/")
const $ = window.$; const $ = window.$;
@ -191,13 +188,6 @@ export default class TPMMDEditor extends Component {
initValue: '' initValue: ''
} }
} }
componentDidUpdate(prevProps, prevState) {
// 不能加,影响了试卷填空题
// if (this.props.initValue != prevProps.initValue) {
// this.answers_editormd.setValue(this.props.initValue)
// }
}
// react_mdEditor_ // react_mdEditor_
componentDidMount = () => { componentDidMount = () => {
const { mdID, initValue, placeholder, showNullButton } = this.props; const { mdID, initValue, placeholder, showNullButton } = this.props;

Loading…
Cancel
Save