Merge branch 'release/0.4.5'
This commit is contained in:
@@ -211,9 +211,12 @@
|
|||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="">
|
||||||
|
<el-checkbox v-model="imageFitWidth">Ширина не более размера экрана</el-checkbox>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="">
|
<el-form-item label="">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
Размер не более
|
Высота не более
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-tooltip :open-delay="500" effect="light" placement="top">
|
<el-tooltip :open-delay="500" effect="light" placement="top">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export default class DrawHelper {
|
|||||||
|
|
||||||
let out = `<div style="width: ${this.w}px; height: ${this.h}px;` +
|
let out = `<div style="width: ${this.w}px; height: ${this.h}px;` +
|
||||||
` position: absolute; top: ${this.fontSize*this.textShift}px; color: ${this.textColor}; font: ${font}; ${justify}` +
|
` position: absolute; top: ${this.fontSize*this.textShift}px; color: ${this.textColor}; font: ${font}; ${justify}` +
|
||||||
` line-height: ${this.lineHeight}px; white-space: nowrap;">`;
|
` line-height: ${this.lineHeight}px; white-space: nowrap; overflow: hidden;">`;
|
||||||
|
|
||||||
let imageDrawn = new Set();
|
let imageDrawn = new Set();
|
||||||
let len = lines.length;
|
let len = lines.length;
|
||||||
@@ -100,23 +100,18 @@ export default class DrawHelper {
|
|||||||
space = (part.style.space > space ? part.style.space : space);
|
space = (part.style.space > space ? part.style.space : space);
|
||||||
|
|
||||||
//избражения
|
//избражения
|
||||||
//image: {local: Boolean, inline: Boolean, id: String, imageLine: Number, lineCount: Number, paraIndex: Number},
|
//image: {local: Boolean, inline: Boolean, id: String, imageLine: Number, lineCount: Number, paraIndex: Number, w: Number, h: Number},
|
||||||
const img = part.image;
|
const img = part.image;
|
||||||
if (img && img.id && !img.inline && !imageDrawn.has(img.paraIndex)) {
|
if (img && img.id && !img.inline && !imageDrawn.has(img.paraIndex)) {
|
||||||
const bin = this.parsed.binary[img.id];
|
const bin = this.parsed.binary[img.id];
|
||||||
if (bin) {
|
if (bin) {
|
||||||
let imgH = img.lineCount*this.lineHeight;
|
|
||||||
imgH = (imgH <= bin.h ? imgH : bin.h);
|
|
||||||
let imgW = bin.w;
|
|
||||||
|
|
||||||
let resize = '';
|
let resize = '';
|
||||||
if (bin.h > imgH) {
|
if (bin.h > img.h) {
|
||||||
resize = `height: ${imgH}px`;
|
resize = `height: ${img.h}px`;
|
||||||
imgW = imgW*imgH/bin.h;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const left = (this.w - imgW)/2;
|
const left = (this.w - img.w)/2;
|
||||||
const top = ((img.lineCount*this.lineHeight - imgH)/2) + (i - img.imageLine)*this.lineHeight;
|
const top = ((img.lineCount*this.lineHeight - img.h)/2) + (i - img.imageLine)*this.lineHeight;
|
||||||
if (img.local) {
|
if (img.local) {
|
||||||
lineText += `<img src="data:${bin.type};base64,${bin.data}" style="position: absolute; left: ${left}px; top: ${top}px; ${resize}"/>`;
|
lineText += `<img src="data:${bin.type};base64,${bin.data}" style="position: absolute; left: ${left}px; top: ${top}px; ${resize}"/>`;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -221,6 +221,7 @@ class TextPage extends Vue {
|
|||||||
this.parsed.showImages = this.showImages;
|
this.parsed.showImages = this.showImages;
|
||||||
this.parsed.showInlineImagesInCenter = this.showInlineImagesInCenter;
|
this.parsed.showInlineImagesInCenter = this.showInlineImagesInCenter;
|
||||||
this.parsed.imageHeightLines = this.imageHeightLines;
|
this.parsed.imageHeightLines = this.imageHeightLines;
|
||||||
|
this.parsed.imageFitWidth = this.imageFitWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
//statusBar
|
//statusBar
|
||||||
|
|||||||
@@ -609,7 +609,8 @@ export default class BookParser {
|
|||||||
para.parsed.cutEmptyParagraphs === this.cutEmptyParagraphs &&
|
para.parsed.cutEmptyParagraphs === this.cutEmptyParagraphs &&
|
||||||
para.parsed.addEmptyParagraphs === this.addEmptyParagraphs &&
|
para.parsed.addEmptyParagraphs === this.addEmptyParagraphs &&
|
||||||
para.parsed.showImages === this.showImages &&
|
para.parsed.showImages === this.showImages &&
|
||||||
para.parsed.imageHeightLines === this.imageHeightLines
|
para.parsed.imageHeightLines === this.imageHeightLines &&
|
||||||
|
para.parsed.imageFitWidth === this.imageFitWidth
|
||||||
)
|
)
|
||||||
return para.parsed;
|
return para.parsed;
|
||||||
|
|
||||||
@@ -623,6 +624,7 @@ export default class BookParser {
|
|||||||
addEmptyParagraphs: this.addEmptyParagraphs,
|
addEmptyParagraphs: this.addEmptyParagraphs,
|
||||||
showImages: this.showImages,
|
showImages: this.showImages,
|
||||||
imageHeightLines: this.imageHeightLines,
|
imageHeightLines: this.imageHeightLines,
|
||||||
|
imageFitWidth: this.imageFitWidth,
|
||||||
visible: !(
|
visible: !(
|
||||||
(this.cutEmptyParagraphs && para.cut) ||
|
(this.cutEmptyParagraphs && para.cut) ||
|
||||||
(para.addIndex > this.addEmptyParagraphs)
|
(para.addIndex > this.addEmptyParagraphs)
|
||||||
@@ -638,7 +640,7 @@ export default class BookParser {
|
|||||||
last: Boolean,
|
last: Boolean,
|
||||||
parts: array of {
|
parts: array of {
|
||||||
style: {bold: Boolean, italic: Boolean, center: Boolean},
|
style: {bold: Boolean, italic: Boolean, center: Boolean},
|
||||||
image: {local: Boolean, inline: Boolean, id: String, imageLine: Number, lineCount: Number, paraIndex: Number},
|
image: {local: Boolean, inline: Boolean, id: String, imageLine: Number, lineCount: Number, paraIndex: Number, w: Number, h: Number},
|
||||||
text: String,
|
text: String,
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
@@ -666,8 +668,21 @@ export default class BookParser {
|
|||||||
bin = {h: 0, w: 0};
|
bin = {h: 0, w: 0};
|
||||||
|
|
||||||
let lineCount = this.imageHeightLines;
|
let lineCount = this.imageHeightLines;
|
||||||
const c = Math.ceil(bin.h/this.lineHeight);
|
let c = Math.ceil(bin.h/this.lineHeight);
|
||||||
|
|
||||||
|
const maxH = lineCount*this.lineHeight;
|
||||||
|
let maxH2 = maxH;
|
||||||
|
if (this.imageFitWidth && bin.w > this.w) {
|
||||||
|
maxH2 = bin.h*this.w/bin.w;
|
||||||
|
c = Math.ceil(maxH2/this.lineHeight);
|
||||||
|
}
|
||||||
lineCount = (c < lineCount ? c : lineCount);
|
lineCount = (c < lineCount ? c : lineCount);
|
||||||
|
|
||||||
|
let imageHeight = (maxH2 < maxH ? maxH2 : maxH);
|
||||||
|
imageHeight = (imageHeight <= bin.h ? imageHeight : bin.h);
|
||||||
|
|
||||||
|
let imageWidth = (bin.h > imageHeight ? bin.w*imageHeight/bin.h : bin.w);
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (; i < lineCount - 1; i++) {
|
for (; i < lineCount - 1; i++) {
|
||||||
line.end = para.offset + ofs;
|
line.end = para.offset + ofs;
|
||||||
@@ -679,7 +694,9 @@ export default class BookParser {
|
|||||||
id: part.image.id,
|
id: part.image.id,
|
||||||
imageLine: i,
|
imageLine: i,
|
||||||
lineCount,
|
lineCount,
|
||||||
paraIndex
|
paraIndex,
|
||||||
|
w: imageWidth,
|
||||||
|
h: imageHeight,
|
||||||
}});
|
}});
|
||||||
lines.push(line);
|
lines.push(line);
|
||||||
line = {begin: line.end + 1, parts: []};
|
line = {begin: line.end + 1, parts: []};
|
||||||
@@ -689,7 +706,9 @@ export default class BookParser {
|
|||||||
line.first = (j == 0);
|
line.first = (j == 0);
|
||||||
line.last = true;
|
line.last = true;
|
||||||
line.parts.push({style, text: ' ',
|
line.parts.push({style, text: ' ',
|
||||||
image: {local: part.image.local, inline: false, id: part.image.id, imageLine: i, lineCount, paraIndex}});
|
image: {local: part.image.local, inline: false, id: part.image.id,
|
||||||
|
imageLine: i, lineCount, paraIndex, w: imageWidth, h: imageHeight}
|
||||||
|
});
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ const settingDefaults = {
|
|||||||
showImages: true,
|
showImages: true,
|
||||||
showInlineImagesInCenter: false,
|
showInlineImagesInCenter: false,
|
||||||
imageHeightLines: 100,
|
imageHeightLines: 100,
|
||||||
|
imageFitWidth: true,
|
||||||
|
|
||||||
fontShifts: {},
|
fontShifts: {},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Liberama",
|
"name": "Liberama",
|
||||||
"version": "0.4.4",
|
"version": "0.4.5",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.0.0"
|
"node": ">=10.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user