Browse Source

富文本组件带拼音时预览不进行拼音校正

zq 2 weeks ago
parent
commit
8f199516c4

+ 12 - 6
src/components/PinyinText.vue

@@ -11,7 +11,12 @@
           <span v-if="pinyinPosition === 'top'" class="pinyin">
             {{ text.pinyin.replace(/\s+/g, '') }}
           </span>
-          <span class="text" title="点击校对拼音" @click="correctPinyin1(text.text, i, j, k)">{{ text.text }}</span>
+          <span
+            :style="{ cursor: isPreview ? '' : 'pointer' }"
+            :title="isPreview ? '' : '点击校对拼音'"
+            @click="correctPinyin(text.text, i, j, k)"
+            >{{ text.text }}</span
+          >
           <span v-if="pinyinPosition === 'bottom'" class="pinyin">{{ text.pinyin.replace(/\s+/g, '') }}</span>
         </div>
       </div>
@@ -36,6 +41,10 @@ export default {
       type: String,
       required: true,
     },
+    isPreview: {
+      type: Boolean,
+      default: false,
+    },
   },
   data() {
     return {
@@ -49,7 +58,8 @@ export default {
   },
   methods: {
     // 校对拼音
-    correctPinyin1(text, i, j, k) {
+    correctPinyin(text, i, j, k) {
+      if (this.isPreview) return; // 如果是预览模式,不操作
       if (text) {
         this.visible = true;
         this.selectContent = text;
@@ -93,10 +103,6 @@ export default {
           font-family: 'League';
           font-size: 12px;
         }
-
-        .text {
-          cursor: pointer;
-        }
       }
     }
   }

+ 2 - 0
src/views/book/courseware/preview/components/rich_text/RichTextPreview.vue

@@ -8,6 +8,7 @@
           v-if="isEnable(data.property.view_pinyin)"
           :paragraph-list="data.paragraph_list"
           :pinyin-position="data.property.pinyin_position"
+          :is-preview="isPreview"
         />
         <span v-else class="rich-text" v-html="sanitizeHTML(data.content)" @click="handleRichFillClick"></span>
       </div>
@@ -41,6 +42,7 @@ export default {
       isEnable,
       data: getRichTextData(),
       selectedNoteId: '',
+      isPreview: true,
     };
   },
   methods: {