|
@@ -224,9 +224,9 @@ export default {
|
|
// });
|
|
// });
|
|
this.resetData(this.data);
|
|
this.resetData(this.data);
|
|
|
|
|
|
- // this.$nextTick(() => {
|
|
|
|
- // this.registScrollEvent();
|
|
|
|
- // });
|
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.registScrollEvent();
|
|
|
|
+ });
|
|
},
|
|
},
|
|
resetData({ richText, detailInfo }) {
|
|
resetData({ richText, detailInfo }) {
|
|
this.paperData = deepCopy(detailInfo);
|
|
this.paperData = deepCopy(detailInfo);
|
|
@@ -394,6 +394,14 @@ export default {
|
|
open() {
|
|
open() {
|
|
this.modalIsShow = true;
|
|
this.modalIsShow = true;
|
|
},
|
|
},
|
|
|
|
+ getRichTextJsons() {
|
|
|
|
+ let sections = [];
|
|
|
|
+ this.$refs.RichTextEditor.forEach((item) => {
|
|
|
|
+ const itemRichJson = item.emitJsonAction();
|
|
|
|
+ sections.push(...itemRichJson.sections);
|
|
|
|
+ });
|
|
|
|
+ return { sections };
|
|
|
|
+ },
|
|
async toParse() {
|
|
async toParse() {
|
|
if (isAnEmptyRichText(this.paperRichJson)) {
|
|
if (isAnEmptyRichText(this.paperRichJson)) {
|
|
this.$message.error("请输入试卷内容!");
|
|
this.$message.error("请输入试卷内容!");
|
|
@@ -403,12 +411,7 @@ export default {
|
|
if (this.loading) return;
|
|
if (this.loading) return;
|
|
this.loading = true;
|
|
this.loading = true;
|
|
|
|
|
|
- let richText = this.$refs.RichTextEditor.emitJsonAction();
|
|
|
|
- richText.sections = richText.sections.filter(
|
|
|
|
- (item) =>
|
|
|
|
- !item.attributes || item.attributes["class"] !== "section-error"
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
|
|
+ let richText = this.getRichTextJsons();
|
|
const res = await questionImportParseRichText({
|
|
const res = await questionImportParseRichText({
|
|
richText,
|
|
richText,
|
|
courseId: this.data.importData.courseId,
|
|
courseId: this.data.importData.courseId,
|
|
@@ -853,17 +856,17 @@ export default {
|
|
document
|
|
document
|
|
.getElementById("qe-part-paper")
|
|
.getElementById("qe-part-paper")
|
|
.addEventListener("scroll", this.paperScrollEvent);
|
|
.addEventListener("scroll", this.paperScrollEvent);
|
|
- this.$refs.RichTextEditor.$el
|
|
|
|
- .querySelector(".v-editor-container")
|
|
|
|
- .addEventListener("scroll", this.richTextScrollEvent);
|
|
|
|
|
|
+ document
|
|
|
|
+ .getElementById("qe-part-richtext-list")
|
|
|
|
+ .parentNode.addEventListener("scroll", this.richTextScrollEvent);
|
|
},
|
|
},
|
|
removeScrollEvent() {
|
|
removeScrollEvent() {
|
|
document
|
|
document
|
|
.getElementById("qe-part-paper")
|
|
.getElementById("qe-part-paper")
|
|
.removeEventListener("scroll", this.paperScrollEvent);
|
|
.removeEventListener("scroll", this.paperScrollEvent);
|
|
- this.$refs.RichTextEditor.$el
|
|
|
|
- .querySelector(".v-editor-container")
|
|
|
|
- .removeEventListener("scroll", this.richTextScrollEvent);
|
|
|
|
|
|
+ document
|
|
|
|
+ .getElementById("qe-part-richtext-list")
|
|
|
|
+ .parentNode.removeEventListener("scroll", this.richTextScrollEvent);
|
|
},
|
|
},
|
|
paperScrollEvent(e) {
|
|
paperScrollEvent(e) {
|
|
// e.preventDefault();
|
|
// e.preventDefault();
|
|
@@ -906,20 +909,21 @@ export default {
|
|
);
|
|
);
|
|
if (!richTextSectionDom) return;
|
|
if (!richTextSectionDom) return;
|
|
|
|
|
|
- const richTextContainerDom = this.$refs.RichTextEditor.$el.querySelector(
|
|
|
|
- ".v-editor-container"
|
|
|
|
- );
|
|
|
|
- const richTextMainDom =
|
|
|
|
- this.$refs.RichTextEditor.$el.querySelector(".v-editor-main");
|
|
|
|
- const sectionOffsetTop = richTextSectionDom.offsetTop;
|
|
|
|
- let nextSectionOffsetTop = richTextMainDom.offsetHeight;
|
|
|
|
|
|
+ const richTextListDom = document.getElementById("qe-part-richtext-list");
|
|
|
|
+ const elPos = richTextListDom.getBoundingClientRect();
|
|
|
|
+ const richTextContainerDom = richTextListDom.parentNode;
|
|
|
|
+
|
|
|
|
+ const sectionOffsetTop =
|
|
|
|
+ richTextSectionDom.getBoundingClientRect().y - elPos.y;
|
|
|
|
+ let nextSectionOffsetTop = richTextListDom.offsetHeight;
|
|
|
|
|
|
if (nextTargetCont) {
|
|
if (nextTargetCont) {
|
|
const nextRichTextSectionDom = document.getElementById(
|
|
const nextRichTextSectionDom = document.getElementById(
|
|
`section-${nextTargetCont[2][0]}`
|
|
`section-${nextTargetCont[2][0]}`
|
|
);
|
|
);
|
|
if (nextRichTextSectionDom) {
|
|
if (nextRichTextSectionDom) {
|
|
- nextSectionOffsetTop = nextRichTextSectionDom.offsetTop;
|
|
|
|
|
|
+ nextSectionOffsetTop =
|
|
|
|
+ nextRichTextSectionDom.getBoundingClientRect().y - elPos.y;
|
|
} else {
|
|
} else {
|
|
nextSectionOffsetTop =
|
|
nextSectionOffsetTop =
|
|
richTextSectionDom.offsetTop + richTextSectionDom.offsetHeight;
|
|
richTextSectionDom.offsetTop + richTextSectionDom.offsetHeight;
|
|
@@ -942,10 +946,9 @@ export default {
|
|
},
|
|
},
|
|
richTextScrollEvent(e) {
|
|
richTextScrollEvent(e) {
|
|
if (this.scrollType === "paper") {
|
|
if (this.scrollType === "paper") {
|
|
- this.lastRichTextScrollTop =
|
|
|
|
- this.$refs.RichTextEditor.$el.querySelector(
|
|
|
|
- ".v-editor-container"
|
|
|
|
- ).scrollTop;
|
|
|
|
|
|
+ this.lastRichTextScrollTop = document.getElementById(
|
|
|
|
+ "qe-part-richtext-list"
|
|
|
|
+ ).parentNode.scrollTop;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
this.scrollType = "rich-text";
|
|
this.scrollType = "rich-text";
|
|
@@ -959,8 +962,8 @@ export default {
|
|
const offsetH = isScrollDown ? 150 : 0;
|
|
const offsetH = isScrollDown ? 150 : 0;
|
|
const scrollTop = e.target.scrollTop + offsetH;
|
|
const scrollTop = e.target.scrollTop + offsetH;
|
|
|
|
|
|
- const richTextMainDom =
|
|
|
|
- this.$refs.RichTextEditor.$el.querySelector(".v-editor-main");
|
|
|
|
|
|
+ const richTextListDom = document.getElementById("qe-part-richtext-list");
|
|
|
|
+
|
|
const questionContIndexList =
|
|
const questionContIndexList =
|
|
this.$refs.QuestionImportPaperEdit.questionContIndexList;
|
|
this.$refs.QuestionImportPaperEdit.questionContIndexList;
|
|
|
|
|
|
@@ -997,7 +1000,7 @@ export default {
|
|
(scrollTop - targeCont[1]) / (nextTargetCont[1] - targeCont[1]);
|
|
(scrollTop - targeCont[1]) / (nextTargetCont[1] - targeCont[1]);
|
|
} else {
|
|
} else {
|
|
targeCont = this.richTextIndexList.slice(-1)[0];
|
|
targeCont = this.richTextIndexList.slice(-1)[0];
|
|
- const textHeight = richTextMainDom.offsetHeight;
|
|
|
|
|
|
+ const textHeight = richTextListDom.offsetHeight;
|
|
targeContPercent =
|
|
targeContPercent =
|
|
(scrollTop - targeCont[1]) / (textHeight - targeCont[1]);
|
|
(scrollTop - targeCont[1]) / (textHeight - targeCont[1]);
|
|
}
|
|
}
|