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