Merge branch 'hotfix/0.4.1'
This commit is contained in:
@@ -201,7 +201,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') {
|
||||
|
||||
@@ -203,6 +203,16 @@
|
||||
|
||||
</el-col>
|
||||
<el-col :span="11">
|
||||
<el-tooltip :open-delay="500" effect="light" placement="top">
|
||||
<template slot="content">
|
||||
Выносить все изображения в центр экрана
|
||||
</template>
|
||||
<el-checkbox v-model="showInlineImagesInCenter" @change="needReload">Инлайн в центр</el-checkbox>
|
||||
</el-tooltip>
|
||||
</el-col>
|
||||
</el-form-item>
|
||||
<el-form-item label="">
|
||||
Размер изображения
|
||||
<el-tooltip :open-delay="500" effect="light" placement="top">
|
||||
<template slot="content">
|
||||
Определяет высоту изображения количеством строк.<br>
|
||||
@@ -212,7 +222,6 @@
|
||||
</template>
|
||||
<el-input-number v-model="imageHeightLines" :min="1" :max="100"></el-input-number>
|
||||
</el-tooltip>
|
||||
</el-col>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
|
||||
@@ -219,6 +219,7 @@ class TextPage extends Vue {
|
||||
this.parsed.measureText = this.drawHelper.measureText.bind(this.drawHelper);
|
||||
this.parsed.lineHeight = this.lineHeight;
|
||||
this.parsed.showImages = this.showImages;
|
||||
this.parsed.showInlineImagesInCenter = this.showInlineImagesInCenter;
|
||||
this.parsed.imageHeightLines = this.imageHeightLines;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,11 @@ import {sleep} from '../../../share/utils';
|
||||
const maxImageLineCount = 100;
|
||||
|
||||
export default class BookParser {
|
||||
constructor() {
|
||||
constructor(settings) {
|
||||
if (settings) {
|
||||
this.showInlineImagesInCenter = settings.showInlineImagesInCenter;
|
||||
}
|
||||
|
||||
// defaults
|
||||
this.p = 30;// px, отступ параграфа
|
||||
this.w = 300;// px, ширина страницы
|
||||
@@ -151,10 +155,13 @@ export default class BookParser {
|
||||
if (tag == 'image') {
|
||||
let attrs = sax.getAttrsSync(tail);
|
||||
if (attrs.href.value) {
|
||||
if (inPara)
|
||||
if (inPara && !this.showInlineImagesInCenter)
|
||||
growParagraph(`<image-inline href="${attrs.href.value}"></image-inline>`, 0);
|
||||
else
|
||||
newParagraph(`<image href="${attrs.href.value}">${' '.repeat(maxImageLineCount)}</image>`, maxImageLineCount);
|
||||
|
||||
if (inPara && this.showInlineImagesInCenter)
|
||||
newParagraph(' ', 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@ const bmRecentStore = localForage.createInstance({
|
||||
});
|
||||
|
||||
class BookManager {
|
||||
async init() {
|
||||
async init(settings) {
|
||||
this.settings = settings;
|
||||
this.books = {};
|
||||
this.recent = {};
|
||||
this.recentChanged1 = true;
|
||||
@@ -131,7 +132,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, {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import Vue from 'vue';
|
||||
|
||||
const fonts = [
|
||||
{name: 'ReaderDefault', label: 'По-умолчанию', fontVertShift: 0},
|
||||
{name: 'GEO_1', label: 'BPG Arial', fontVertShift: 10},
|
||||
@@ -164,6 +162,7 @@ const settingDefaults = {
|
||||
addEmptyParagraphs: 0,
|
||||
blinkCachedLoad: true,
|
||||
showImages: true,
|
||||
showInlineImagesInCenter: false,
|
||||
imageHeightLines: 100,
|
||||
|
||||
fontShifts: {},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Liberama",
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.1",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user