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

优化富文本缩进引起的间隔问题

zq пре 1 месец
родитељ
комит
243accfe6c
1 измењених фајлова са 12 додато и 1 уклоњено
  1. 12 1
      src/components/PinyinText.vue

+ 12 - 1
src/components/PinyinText.vue

@@ -15,7 +15,10 @@
           v-if="block.type === 'text'"
           :key="'text-' + index"
           class="pinyin-sentence"
-          :style="[{ 'align-items': pinyinPosition === 'top' ? 'flex-end' : 'flex-start' }]"
+          :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
@@ -677,6 +680,13 @@ export default {
 
       const styleObj = combinedStyle ? this.parseStyleToObject(combinedStyle) : null;
 
+      // 提取 paddingLeft 用于段落缩进,从 styleObj 中移除
+      const sentenceStyle = {};
+      if (styleObj && styleObj.paddingLeft) {
+        sentenceStyle.paddingLeft = styleObj.paddingLeft;
+        delete styleObj.paddingLeft;
+      }
+
       return {
         type: 'text',
         word_list: item.word_list,
@@ -684,6 +694,7 @@ export default {
         oldIndex,
         paragraphIndex,
         styleObj,
+        sentenceStyle,
         rawStyleText: combinedStyle,
         hasEmphasisDot,
       };