Добавлена настройка addEmptyParagraphs
This commit is contained in:
@@ -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>
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -161,7 +161,8 @@ const settingDefaults = {
|
|||||||
showClickMapPage: true,
|
showClickMapPage: true,
|
||||||
clickControl: true,
|
clickControl: true,
|
||||||
cutEmptyParagraphs: false,
|
cutEmptyParagraphs: false,
|
||||||
|
addEmptyParagraphs: 0,
|
||||||
|
|
||||||
fontShifts: {},
|
fontShifts: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user