Browse Source

语音矩阵设置富文本样式

dsy 1 month ago
parent
commit
eb53958a7f

+ 1 - 1
.env

@@ -11,4 +11,4 @@ VUE_APP_BookWebSI = '/GCLSBookWebSI/ServiceInterface'
 VUE_APP_EepServer = '/EEPServer/SI'
 
 #version
-VUE_APP_VERSION = '2026.07.09'
+VUE_APP_VERSION = '2026.07.11'

+ 5 - 0
package.json

@@ -95,6 +95,11 @@
     "asarUnpack": [
       "node_modules/7zip-bin/**"
     ],
+    "files": [
+      "**/*",
+      "!packages/**",
+      "!packages"
+    ],
     "directories": {
       "output": "out"
     },

+ 11 - 3
src/components/PinyinText.vue

@@ -17,7 +17,12 @@
           class="pinyin-sentence"
           :style="[{ 'align-items': pinyinPosition === 'top' ? 'flex-end' : 'flex-start' }, block.sentenceStyle]"
         >
-          <span v-for="(word, wIndex) in block.word_list" :key="wIndex" class="pinyin-text" :style="block.styleObj">
+          <span
+            v-for="(word, wIndex) in block.word_list"
+            :key="wIndex"
+            :class="['pinyin-text', { spacing: isShowPinyin }]"
+            :style="block.styleObj"
+          >
             <span
               :title="isPreview ? '' : '点击校对'"
               :style="{
@@ -128,7 +133,7 @@
           class="pinyin-sentence"
           :style="{ 'align-items': pinyinPosition === 'top' ? 'flex-end' : 'flex-start' }"
         >
-          <span v-for="(word, wIndex) in sentence" :key="wIndex" class="pinyin-text">
+          <span v-for="(word, wIndex) in sentence" :key="wIndex" :class="['pinyin-text', { spacing: isShowPinyin }]">
             <span
               :title="isPreview ? '' : '点击校对'"
               :style="{
@@ -1016,10 +1021,13 @@ export default {
 
   .pinyin-text {
     display: inline-flex;
-    padding: 0 2px;
     text-wrap: pretty;
     hanging-punctuation: allow-end;
 
+    &.spacing {
+      padding: 0 2px;
+    }
+
     > span {
       display: inline-flex;
     }

+ 19 - 2
src/components/RichText.vue

@@ -876,8 +876,9 @@ export default {
      * 设置整体富文本格式
      * @param {string} type 格式名称
      * @param {string} val 格式值
+     * @param {boolean} [isSetDefault=false] 是否设置为默认格式
      */
-    setRichFormat(type, val) {
+    setRichFormat(type, val, isSetDefault = false) {
       let editor = tinymce.get(this.id);
       if (!editor) return;
       editor.execCommand('SelectAll');
@@ -885,6 +886,10 @@ export default {
       editor.selection.collapse(false);
       editor.fire('change'); // 触发内容变化事件,确保内容更新
 
+      if (isSetDefault) {
+        this.setDefaultRichtext(editor, type, val);
+      }
+
       if (this.isViewPinyin) {
         this.$nextTick(() => {
           let styles = this.getFirstCharStyles();
@@ -893,7 +898,8 @@ export default {
       }
     },
     /**
-     * 设置整体富文本格式
+     * 处理编辑器格式化逻辑
+     * @param {Editor} editor 编辑器实例
      * @param {string} type 格式名称
      * @param {string} val 格式值
      */
@@ -937,6 +943,17 @@ export default {
         }
       }
     },
+    /**
+     * 设置默认富文本格式
+     * @param {Editor} editor 编辑器实例
+     * @param {string} type 格式名称
+     * @param {string} val 格式值
+     */
+    setDefaultRichtext(editor, type, val) {
+      const bodyStyle = editor.getBody().style;
+      if (!bodyStyle) return;
+      bodyStyle[type] = val;
+    },
     setRichTitleFormat(config) {
       if (!this.editorIsInited) {
         this.editorBeforeInitConfig['style'] = config;

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

@@ -285,7 +285,7 @@ export default {
      */
     BatchSetFormat(text, val = '') {
       this.$refs.richText.forEach((richText) => {
-        richText.setRichFormat(text, val);
+        richText.setRichFormat(text, val, true);
       });
     },
     /**