Commit 9bb63fd4 by yuananting

fix:调试

parent ff15b763
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-02-25 14:34:29
* @LastEditors: yuananting
* @LastEditTime: 2021-03-25 18:50:43
* @LastEditTime: 2021-03-25 19:10:32
* @Description: 助学工具-题库-题目管理-新建题目Tab
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......@@ -596,10 +596,13 @@ class NewQuestionTab extends Component {
data.forEach((item, index) => {
if (index === idx) {
if (_gap.length < data.length) {
console.log(1)
_gap.splice(idx, 0, { correctAnswerList: [] });
} else if (_gap.length > data.length) {
console.log(2)
_gap.splice(idx, 1);
} else {
console.log(3)
_gap.splice(idx, 1, { correctAnswerList: [] });
}
}
......
......@@ -160,60 +160,62 @@ class QuestionEditor extends Component {
}
editorRoot.config.onchange = (html) => {
const conLen = html.replace(/<(?!img|input).*?>/g, "").length;
counter++;
const { focusFlag } = this.state;
const textLength = editorRoot.txt.text().replace(/\&nbsp\;/gi, " ")
.length;
const imgLength = html.match(/<img/g)
? html.match(/<img/g).length * 2
: 0;
const contentLength = imgLength + textLength;
const divHeight = document.getElementById(`editor${editorId}_content`)
.firstChild.offsetHeight;
if (divHeight > 30 || imgLength > 0) {
this.setState({ isShowSingleInput: false });
} else {
this.setState({ isShowSingleInput: true });
}
if (
this.state.isGapFilling &&
this.state.contentType === "QUESTION_STEM"
) {
const stemHtml = this.transferStemDocument(html);
var _blanksList = stemHtml.getElementsByClassName("add-fill-line");
const ids = [..._blanksList].map((item) => item.id);
const isEdit = getParameterByName("id");
if (isEdit && counter === 1) {
const prev = localStorage.getItem("gap_ques_prevList");
prevList = prev && JSON.parse(prev);
setTimeout(() => {
const conLen = html.replace(/<(?!img|input).*?>/g, "").length;
counter++;
const { focusFlag } = this.state;
const textLength = editorRoot.txt.text().replace(/\&nbsp\;/gi, " ")
.length;
const imgLength = html.match(/<img/g)
? html.match(/<img/g).length * 2
: 0;
const contentLength = imgLength + textLength;
const divHeight = document.getElementById(`editor${editorId}_content`)
.firstChild.offsetHeight;
if (divHeight > 30 || imgLength > 0) {
this.setState({ isShowSingleInput: false });
} else {
this.setState({ isShowSingleInput: true });
}
if (
this.state.isGapFilling &&
this.state.contentType === "QUESTION_STEM"
) {
const stemHtml = this.transferStemDocument(html);
var _blanksList = stemHtml.getElementsByClassName("add-fill-line");
const ids = [..._blanksList].map((item) => item.id);
let idx = 0;
if (prevList && ids) {
console.log(prevList, ids)
idx = this.getNewArr(prevList, ids);
const oldLen = prevList.length;
idx = idx >= oldLen ? idx - oldLen : idx;
}
const isEdit = getParameterByName("id");
if (isEdit && counter === 1) {
const prev = localStorage.getItem("gap_ques_prevList");
prevList = prev && JSON.parse(prev);
}
prevList = [...ids];
let idx = 0;
if (prevList && ids) {
console.log(prevList, ids);
idx = this.getNewArr(prevList, ids);
const oldLen = prevList.length;
idx = idx >= oldLen ? idx - oldLen : idx;
}
this.setState({ blanksList: _blanksList }, () =>
this.props.changeBlankCount(_blanksList, idx)
);
}
this.setState(
{
contentLength,
visiblePlacehold:
(conLen === 0 || (conLen === 1 && html === " ")) && !focusFlag,
},
() => {
onChange && onChange(html, this.state.contentLength);
prevList = [...ids];
this.setState({ blanksList: _blanksList }, () =>
this.props.changeBlankCount(_blanksList, idx)
);
}
);
this.setState(
{
contentLength,
visiblePlacehold:
(conLen === 0 || (conLen === 1 && html === " ")) && !focusFlag,
},
() => {
onChange && onChange(html, this.state.contentLength);
}
);
}, 0);
};
editorRoot.config.onblur = () => {
......@@ -325,7 +327,10 @@ class QuestionEditor extends Component {
}
style={{
border:
this.props.validateStatus === "error" || contentLength > limitLength ? "1px solid red" : "",
this.props.validateStatus === "error" ||
contentLength > limitLength
? "1px solid red"
: "",
}}
>
<div
......@@ -362,7 +367,15 @@ class QuestionEditor extends Component {
<div className="editor-placehold">{placehold}</div>
)}
{visibleMediaBox && !_.isEmpty(mediaBtn) && (
<div className="edtior-media_box" style={{top: isGapFilling && contentType==="QUESTION_STEM" ? "53%" : "100%"}}>
<div
className="edtior-media_box"
style={{
top:
isGapFilling && contentType === "QUESTION_STEM"
? "53%"
: "100%",
}}
>
<div className="edtior-media_list">
{_.map(mediaBtn, (mediaItem) => {
const mediaBtnMap = _.find(
......
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