Добавил настройку cutEmptyParagraphs
This commit is contained in:
@@ -199,7 +199,7 @@ class Reader extends Vue {
|
||||
|
||||
mounted() {
|
||||
(async() => {
|
||||
await bookManager.init();
|
||||
await bookManager.init(this.settings);
|
||||
await restoreOldSettings(this.settings, bookManager, this.commit);
|
||||
|
||||
if (this.$root.rootRoute == '/reader') {
|
||||
|
||||
@@ -184,6 +184,10 @@
|
||||
<el-checkbox v-model="textAlignJustify">По ширине</el-checkbox>
|
||||
<el-checkbox v-model="wordWrap">Перенос по слогам</el-checkbox>
|
||||
</el-form-item>
|
||||
<el-form-item label="Обработка">
|
||||
<el-checkbox v-model="cutEmptyParagraphs" @change="needReload">Убирать пустые параграфы</el-checkbox>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
|
||||
<el-form :model="form" size="mini" label-width="120px" @submit.native.prevent>
|
||||
@@ -387,6 +391,10 @@ class SettingsPage extends Vue {
|
||||
];
|
||||
}
|
||||
|
||||
needReload() {
|
||||
this.$notify.warning({message: 'Необходимо обновить страницу (F5), чтобы изменения возымели эффект'});
|
||||
}
|
||||
|
||||
close() {
|
||||
this.$emit('settings-toggle');
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import sax from '../../../../server/core/BookConverter/sax';
|
||||
import {sleep} from '../../../share/utils';
|
||||
|
||||
export default class BookParser {
|
||||
constructor() {
|
||||
constructor(settings) {
|
||||
// defaults
|
||||
this.p = 30;// px, отступ параграфа
|
||||
this.w = 300;// px, ширина страницы
|
||||
@@ -13,6 +13,11 @@ export default class BookParser {
|
||||
this.measureText = (text, style) => {// eslint-disable-line no-unused-vars
|
||||
return text.length*20;
|
||||
};
|
||||
|
||||
//настройки
|
||||
if (settings) {
|
||||
this.cutEmptyParagraphs = settings.cutEmptyParagraphs;
|
||||
}
|
||||
}
|
||||
|
||||
async parse(data, callback) {
|
||||
@@ -49,6 +54,13 @@ export default class BookParser {
|
||||
}
|
||||
*/
|
||||
const newParagraph = (text, len) => {
|
||||
//схлопывание пустых параграфов
|
||||
if (this.cutEmptyParagraphs && paraIndex >= 0) {
|
||||
let p = para[paraIndex];
|
||||
if (p.length == 1 && p.text[0] == ' ')
|
||||
return;
|
||||
}
|
||||
|
||||
paraIndex++;
|
||||
let p = {
|
||||
index: paraIndex,
|
||||
|
||||
@@ -18,7 +18,8 @@ const bmRecentStore = localForage.createInstance({
|
||||
});
|
||||
|
||||
class BookManager {
|
||||
async init() {
|
||||
async init(settings) {
|
||||
this.settings = settings;
|
||||
this.books = {};
|
||||
this.recent = {};
|
||||
this.recentChanged = true;
|
||||
@@ -130,7 +131,7 @@ class BookManager {
|
||||
async parseBook(meta, data, callback) {
|
||||
if (!this.books)
|
||||
await this.init();
|
||||
const parsed = new BookParser();
|
||||
const parsed = new BookParser(this.settings);
|
||||
|
||||
const parsedMeta = await parsed.parse(data, callback);
|
||||
const result = Object.assign({}, meta, parsedMeta, {
|
||||
|
||||
@@ -160,6 +160,8 @@ const settingDefaults = {
|
||||
copyFullText: false,
|
||||
showClickMapPage: true,
|
||||
clickControl: true,
|
||||
cutEmptyParagraphs: false,
|
||||
|
||||
fontShifts: {},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user