Explorar o código

Добавлена настройка addEmptyParagraphs

Book Pauk %!s(int64=6) %!d(string=hai) anos
pai
achega
550dcbc081

+ 6 - 0
client/components/Reader/SettingsPage/SettingsPage.vue

@@ -187,6 +187,12 @@
                             <el-form-item label="Обработка">
                             <el-form-item label="Обработка">
                                 <el-checkbox v-model="cutEmptyParagraphs" @change="needReload">Убирать пустые параграфы</el-checkbox>
                                 <el-checkbox v-model="cutEmptyParagraphs" @change="needReload">Убирать пустые параграфы</el-checkbox>
                             </el-form-item>
                             </el-form-item>
+                            <el-form-item label="">
+                                <el-col :span="12">
+                                    Добавлять пустые
+                                </el-col>
+                                <el-input-number v-model="addEmptyParagraphs" :min="0" :max="2" @change="needReload"></el-input-number>
+                            </el-form-item>
                             
                             
                         </el-form>
                         </el-form>
 
 

+ 13 - 2
client/components/Reader/share/BookParser.js

@@ -17,6 +17,7 @@ export default class BookParser {
         //настройки
         //настройки
         if (settings) {
         if (settings) {
             this.cutEmptyParagraphs = settings.cutEmptyParagraphs;
             this.cutEmptyParagraphs = settings.cutEmptyParagraphs;
+            this.addEmptyParagraphs = settings.addEmptyParagraphs;
         }
         }
     }
     }
 
 
@@ -53,9 +54,9 @@ export default class BookParser {
                 text: String //текст параграфа (или title или epigraph и т.д) с вложенными тегами
                 text: String //текст параграфа (или title или epigraph и т.д) с вложенными тегами
             }
             }
         */
         */
-        const newParagraph = (text, len) => {
+        const newParagraph = (text, len, noCut) => {
             //схлопывание пустых параграфов
             //схлопывание пустых параграфов
-            if (this.cutEmptyParagraphs && paraIndex >= 0) {
+            if (!noCut && this.cutEmptyParagraphs && paraIndex >= 0 && len == 1 && text[0] == ' ') {
                 let p = para[paraIndex];
                 let p = para[paraIndex];
                 if (p.length == 1 && p.text[0] == ' ')
                 if (p.length == 1 && p.text[0] == ' ')
                     return;
                     return;
@@ -82,6 +83,16 @@ export default class BookParser {
 
 
             let p = para[paraIndex];
             let p = para[paraIndex];
             if (p) {
             if (p) {
+                //добавление пустых параграфов
+                if (this.addEmptyParagraphs && p.length == 1 && p.text[0] == ' ' && len > 0) {
+                    let i = this.addEmptyParagraphs;
+                    while (i > 0) {
+                        newParagraph(' ', 1, true);
+                        i--;
+                    }
+                    p = para[paraIndex];
+                }
+
                 paraOffset -= p.length;
                 paraOffset -= p.length;
                 if (p.length == 1 && p.text[0] == ' ' && len > 0) {
                 if (p.length == 1 && p.text[0] == ' ' && len > 0) {
                     p.length = 0;
                     p.length = 0;

+ 2 - 1
client/store/modules/reader.js

@@ -161,7 +161,8 @@ const settingDefaults = {
         showClickMapPage: true,
         showClickMapPage: true,
         clickControl: true,
         clickControl: true,
         cutEmptyParagraphs: false,
         cutEmptyParagraphs: false,
-        
+        addEmptyParagraphs: 0,
+
         fontShifts: {},
         fontShifts: {},
 };
 };