Преглед изворни кода

填空题去除font-size样式

dusenyao пре 1 година
родитељ
комит
a0aa6c2725

+ 6 - 3
src/views/exercise_questions/create/components/exercises/FillQuestion.vue

@@ -107,12 +107,15 @@ export default {
       this.data.model_essay = [];
       this.data.answer.answer_list = [];
       this.data.article
-        .split(/<p>(.*?)<\/p>/gi)
+        .split(/<p .*?>(.*?)<\/p>/gi)
         .filter((item) => item)
         .forEach((item) => {
           if (item.charCodeAt() === 10) return;
-          // 匹配 class 名为 rich-fill 的 span 标签和三个以上的_,并将它们组成数组
-          let str = item.replace(/<span class="rich-fill".*?>(.*?)<\/span>|([_]{3,})/gi, '###$1$2###');
+          let str = item
+            // 去除所有的 font-size 样式
+            .replace(/font-size:\s*\d+(\.\d+)?px;/gi, '')
+            // 匹配 class 名为 rich-fill 的 span 标签和三个以上的_,并将它们组成数组
+            .replace(/<span class="rich-fill".*?>(.*?)<\/span>|([_]{3,})/gi, '###$1$2###');
           this.data.model_essay.push(this.splitRichText(str));
         });
     },

+ 6 - 3
src/views/exercise_questions/create/components/exercises/ListenFillQuestion.vue

@@ -147,12 +147,15 @@ export default {
       this.data.model_essay = [];
       this.data.answer.answer_list = [];
       this.data.article
-        .split(/<p>(.*?)<\/p>/gi)
+        .split(/<p .*?>(.*?)<\/p>/gi)
         .filter((item) => item)
         .forEach((item) => {
           if (item.charCodeAt() === 10) return;
-          // 匹配 class 名为 rich-fill 的 span 标签和三个以上的_,并将它们组成数组
-          let str = item.replace(/<span class="rich-fill".*?>(.*?)<\/span>|([_]{3,})/gi, '###$1$2###');
+          let str = item
+            // 去除所有的 font-size 样式
+            .replace(/font-size:\s*\d+(\.\d+)?px;/gi, '')
+            // 匹配 class 名为 rich-fill 的 span 标签和三个以上的_,并将它们组成数组
+            .replace(/<span class="rich-fill".*?>(.*?)<\/span>|([_]{3,})/gi, '###$1$2###');
           this.data.model_essay.push(this.splitRichText(str));
         });
     },

+ 1 - 1
src/views/exercise_questions/preview/FillPreview.vue

@@ -266,7 +266,7 @@ export default {
 
       :deep input.el-input__inner {
         padding: 0;
-        font-size: 16px;
+        font-size: 16pt;
         color: $font-color;
         text-align: center;
         background-color: #fff;

+ 1 - 1
src/views/exercise_questions/preview/ListenFillPreview.vue

@@ -256,7 +256,7 @@ export default {
 
       :deep input.el-input__inner {
         padding: 0;
-        font-size: 16px;
+        font-size: 16pt;
         color: $font-color;
         text-align: center;
         background-color: #fff;