Browse Source

富文本增加文字颜色初始化,将部分组件的富文本初始化优化

Co-authored-by: Copilot <copilot@github.com>
dsy 1 week ago
parent
commit
3927ecb18d

+ 5 - 0
src/components/RichText.vue

@@ -110,6 +110,10 @@ export default {
       type: String,
       default: 'Arial',
     },
+    fontColor: {
+      type: String,
+      default: '#000000',
+    },
     isHasSpace: {
       type: Boolean,
       default: false,
@@ -205,6 +209,7 @@ export default {
           editor.on('init', () => {
             editor.getBody().style.fontSize = this.init.font_size; // 设置默认字体大小
             editor.getBody().style.fontFamily = this.init.font_family; // 设置默认字体
+            editor.getBody().style.color = this.fontColor; // 设置默认字体颜色
 
             this.init.paragraphheight_formats.forEach((config) => {
               const formatName = `paragraphSpacing${config}_em`;

+ 2 - 0
src/views/book/courseware/create/components/question/fill/Fill.vue

@@ -4,6 +4,7 @@
       <!-- eslint-disable max-len -->
       <div class="fill-wrapper">
         <RichText
+          v-if="property.isGetContent"
           ref="richText"
           v-model="data.content"
           :is-fill="true"
@@ -11,6 +12,7 @@
           :wordlimit-num="false"
           :font-size="data?.unified_attrib?.font_size"
           :font-family="data?.unified_attrib?.font"
+          :font-color="data?.unified_attrib?.text_color"
         />
         <el-input
           v-if="data.property.fill_type === fillTypeList[1].value"

+ 2 - 0
src/views/book/courseware/create/components/question/judge/Judge.vue

@@ -11,10 +11,12 @@
           </span>
           <div class="option-content">
             <RichText
+              v-if="property.isGetContent"
               ref="richText"
               v-model="item.content"
               :font-size="data?.unified_attrib?.font_size"
               :font-family="data?.unified_attrib?.font"
+              :font-color="data?.unified_attrib?.text_color"
               placeholder="输入内容"
               :inline="true"
             />

+ 1 - 0
src/views/book/courseware/create/components/question/matching/Matching.vue

@@ -15,6 +15,7 @@
                 :height="32"
                 :font-size="data?.unified_attrib?.font_size"
                 :font-family="data?.unified_attrib?.font"
+                :font-color="data?.unified_attrib?.text_color"
                 :is-view-pinyin="isEnable(data.property.view_pinyin)"
                 @createParsedTextInfoPinyin="handleParsedTextPinyin($event, i, j)"
               />

+ 2 - 0
src/views/book/courseware/create/components/question/select/Select.vue

@@ -16,10 +16,12 @@
               <SvgIcon icon-class="check-mark" width="10" height="7" />
             </span>
             <RichText
+              v-if="property.isGetContent"
               ref="richText"
               v-model="item.content"
               :font-size="data?.unified_attrib?.font_size"
               :font-family="data?.unified_attrib?.font"
+              :font-color="data?.unified_attrib?.text_color"
               placeholder="输入内容"
               :inline="true"
               :height="32"

+ 2 - 0
src/views/book/courseware/create/components/question/sort/Sort.vue

@@ -11,10 +11,12 @@
             }"
           >
             <RichText
+              v-if="property.isGetContent"
               ref="richText"
               v-model="item.content"
               :font-size="data?.unified_attrib?.font_size"
               :font-family="data?.unified_attrib?.font"
+              :font-color="data?.unified_attrib?.text_color"
               :inline="true"
               placeholder="输入内容"
             />

+ 1 - 0
src/views/book/courseware/create/components/question/voice_matrix/VoiceMatrix.vue

@@ -36,6 +36,7 @@
                 v-model="li.content"
                 :font-size="data?.unified_attrib?.font_size"
                 :font-family="data?.unified_attrib?.font"
+                :font-color="data?.unified_attrib?.text_color"
                 :inline="true"
                 toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright"
               />