|
@@ -337,13 +337,21 @@ export default {
|
|
this.studentAnswer = this.$refs.answerDiv.innerHTML;
|
|
this.studentAnswer = this.$refs.answerDiv.innerHTML;
|
|
},
|
|
},
|
|
textSup() {
|
|
textSup() {
|
|
|
|
+ const origHMTL = this.$refs.answerDiv.innerHTML + "";
|
|
getSelection()
|
|
getSelection()
|
|
.getRangeAt(0)
|
|
.getRangeAt(0)
|
|
.surroundContents(document.createElement("sup"));
|
|
.surroundContents(document.createElement("sup"));
|
|
- this.studentAnswer = this.$refs.answerDiv.innerHTML;
|
|
|
|
|
|
+ if (
|
|
|
|
+ this.$refs.answerDiv.querySelector("sup sup, sub sub, sup sub, sub sup")
|
|
|
|
+ ) {
|
|
|
|
+ console.log("不允许多层上标下标");
|
|
|
|
+ this.$refs.answerDiv.innerHTML = origHMTL;
|
|
|
|
+ } else {
|
|
|
|
+ this.studentAnswer = this.$refs.answerDiv.innerHTML;
|
|
|
|
+ }
|
|
},
|
|
},
|
|
undoTextSup() {
|
|
undoTextSup() {
|
|
- getSelection().modify("extend", "left", "character");
|
|
|
|
|
|
+ // getSelection().modify("extend", "left", "character");
|
|
let selRange = getSelection().getRangeAt(0);
|
|
let selRange = getSelection().getRangeAt(0);
|
|
var documentFragment = selRange.extractContents();
|
|
var documentFragment = selRange.extractContents();
|
|
var text = new Text(documentFragment.textContent);
|
|
var text = new Text(documentFragment.textContent);
|
|
@@ -351,10 +359,18 @@ export default {
|
|
this.studentAnswer = this.$refs.answerDiv.innerHTML;
|
|
this.studentAnswer = this.$refs.answerDiv.innerHTML;
|
|
},
|
|
},
|
|
textSub() {
|
|
textSub() {
|
|
|
|
+ const origHMTL = this.$refs.answerDiv.innerHTML + "";
|
|
getSelection()
|
|
getSelection()
|
|
.getRangeAt(0)
|
|
.getRangeAt(0)
|
|
.surroundContents(document.createElement("sub"));
|
|
.surroundContents(document.createElement("sub"));
|
|
- this.studentAnswer = this.$refs.answerDiv.innerHTML;
|
|
|
|
|
|
+ if (
|
|
|
|
+ this.$refs.answerDiv.querySelector("sup sup, sub sub, sup sub, sub sup")
|
|
|
|
+ ) {
|
|
|
|
+ console.log("不允许多层上标下标");
|
|
|
|
+ this.$refs.answerDiv.innerHTML = origHMTL;
|
|
|
|
+ } else {
|
|
|
|
+ this.studentAnswer = this.$refs.answerDiv.innerHTML;
|
|
|
|
+ }
|
|
},
|
|
},
|
|
textInput($event) {
|
|
textInput($event) {
|
|
// console.log($event.target.innerHTML);
|
|
// console.log($event.target.innerHTML);
|