Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8491c40890 | ||
|
|
dfa7013cbd | ||
|
|
1a7ceb333d | ||
|
|
d3a30b87f4 | ||
|
|
dd61c04d63 | ||
|
|
5496e874c4 | ||
|
|
56d13288ff | ||
|
|
618111ab05 | ||
|
|
55d02495a3 | ||
|
|
83fc586e03 | ||
|
|
ae3dc9b22c | ||
|
|
12e0f9459b | ||
|
|
fd1dd54b99 | ||
|
|
32cbb2a82c | ||
|
|
048b7c08ca | ||
|
|
d98251e34a | ||
|
|
1eea4e8fc1 | ||
|
|
da330bc615 | ||
|
|
1134250954 |
@@ -194,6 +194,26 @@
|
|||||||
<el-input-number v-model="addEmptyParagraphs" :min="0" :max="2"></el-input-number>
|
<el-input-number v-model="addEmptyParagraphs" :min="0" :max="2"></el-input-number>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="Изображения">
|
||||||
|
<el-col :span="11">
|
||||||
|
<el-checkbox v-model="showImages">Показывать</el-checkbox>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="1">
|
||||||
|
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="11">
|
||||||
|
<el-tooltip :open-delay="500" effect="light" placement="top">
|
||||||
|
<template slot="content">
|
||||||
|
Определяет высоту изображения количеством строк.<br>
|
||||||
|
В случае превышения высоты, изображение будет<br>
|
||||||
|
уменьшено с сохранением пропорций так, чтобы<br>
|
||||||
|
помещаться в указанное количество строк.
|
||||||
|
</template>
|
||||||
|
<el-input-number v-model="imageHeightLines" :min="1" :max="100"></el-input-number>
|
||||||
|
</el-tooltip>
|
||||||
|
</el-col>
|
||||||
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-form :model="form" size="mini" label-width="120px" @submit.native.prevent>
|
<el-form :model="form" size="mini" label-width="120px" @submit.native.prevent>
|
||||||
|
|||||||
@@ -26,10 +26,11 @@ export default class DrawHelper {
|
|||||||
const font = this.fontByStyle({});
|
const font = this.fontByStyle({});
|
||||||
const justify = (this.textAlignJustify ? 'text-align: justify; text-align-last: justify;' : '');
|
const justify = (this.textAlignJustify ? 'text-align: justify; text-align-last: justify;' : '');
|
||||||
|
|
||||||
let out = `<div class="layout" 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;">`;
|
` line-height: ${this.lineHeight}px;">`;
|
||||||
|
|
||||||
|
let imageDrawn = new Set();
|
||||||
let len = lines.length;
|
let len = lines.length;
|
||||||
const lineCount = this.pageLineCount + (isScrolling ? 1 : 0);
|
const lineCount = this.pageLineCount + (isScrolling ? 1 : 0);
|
||||||
len = (len > lineCount ? lineCount : len);
|
len = (len > lineCount ? lineCount : len);
|
||||||
@@ -43,11 +44,13 @@ export default class DrawHelper {
|
|||||||
first: Boolean,
|
first: Boolean,
|
||||||
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},
|
||||||
text: String,
|
text: String,
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
let sel = new Set();
|
let sel = new Set();
|
||||||
|
//поиск
|
||||||
if (i == 0 && this.searching) {
|
if (i == 0 && this.searching) {
|
||||||
let pureText = '';
|
let pureText = '';
|
||||||
for (const part of line.parts) {
|
for (const part of line.parts) {
|
||||||
@@ -70,7 +73,9 @@ export default class DrawHelper {
|
|||||||
|
|
||||||
let lineText = '';
|
let lineText = '';
|
||||||
let center = false;
|
let center = false;
|
||||||
|
let space = 0;
|
||||||
let j = 0;
|
let j = 0;
|
||||||
|
//формируем строку
|
||||||
for (const part of line.parts) {
|
for (const part of line.parts) {
|
||||||
let tOpen = (part.style.bold ? '<b>' : '');
|
let tOpen = (part.style.bold ? '<b>' : '');
|
||||||
tOpen += (part.style.italic ? '<i>' : '');
|
tOpen += (part.style.italic ? '<i>' : '');
|
||||||
@@ -86,14 +91,61 @@ export default class DrawHelper {
|
|||||||
} else
|
} else
|
||||||
text = part.text;
|
text = part.text;
|
||||||
|
|
||||||
|
if (text.trim() == '')
|
||||||
|
text = `<span style="white-space: pre">${text}</span>`;
|
||||||
|
|
||||||
lineText += `${tOpen}${text}${tClose}`;
|
lineText += `${tOpen}${text}${tClose}`;
|
||||||
|
|
||||||
center = center || part.style.center;
|
center = center || part.style.center;
|
||||||
|
space = (part.style.space > 0 ? part.style.space : space);
|
||||||
|
|
||||||
|
//избражения
|
||||||
|
//image: {local: Boolean, inline: Boolean, id: String, imageLine: Number, lineCount: Number, paraIndex: Number},
|
||||||
|
const img = part.image;
|
||||||
|
if (img && img.id && !img.inline && !imageDrawn.has(img.paraIndex)) {
|
||||||
|
if (img.local) {
|
||||||
|
const bin = this.parsed.binary[img.id];
|
||||||
|
|
||||||
|
let imgH = img.lineCount*this.lineHeight;
|
||||||
|
imgH = (imgH <= bin.h ? imgH : bin.h);
|
||||||
|
let imgW = bin.w;
|
||||||
|
|
||||||
|
let resize = '';
|
||||||
|
if (bin.h > imgH) {
|
||||||
|
resize = `height: ${imgH}px`;
|
||||||
|
imgW = imgW*imgH/bin.h;
|
||||||
|
}
|
||||||
|
|
||||||
|
const left = (this.w - imgW)/2;
|
||||||
|
const top = ((img.lineCount*this.lineHeight - imgH)/2) + (i - img.imageLine)*this.lineHeight;
|
||||||
|
lineText += `<img src="data:${bin.type};base64,${bin.data}" style="position: absolute; left: ${left}px; top: ${top}px; ${resize}"/>`;
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
imageDrawn.add(img.paraIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (img && img.id && img.inline) {
|
||||||
|
if (img.local) {
|
||||||
|
const bin = this.parsed.binary[img.id];
|
||||||
|
let resize = '';
|
||||||
|
if (bin.h > this.fontSize) {
|
||||||
|
resize = `height: ${this.fontSize - 3}px`;
|
||||||
|
}
|
||||||
|
lineText += `<img src="data:${bin.type};base64,${bin.data}" style="${resize}"/>`;
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const centerStyle = (center ? `text-align: center; text-align-last: center; width: ${this.w}px` : '')
|
const centerStyle = (center ? `text-align: center; text-align-last: center; width: ${this.w}px` : '')
|
||||||
if (line.first)
|
if ((line.first || space) && !center) {
|
||||||
lineText = `<span style="display: inline-block; margin-left: ${this.p}px"></span>${lineText}`;
|
let p = (line.first ? this.p : 0);
|
||||||
|
p = (space ? p + this.p*space : p);
|
||||||
|
lineText = `<span style="display: inline-block; margin-left: ${p}px"></span>${lineText}`;
|
||||||
|
}
|
||||||
|
|
||||||
if (line.last || center)
|
if (line.last || center)
|
||||||
lineText = `<span style="display: inline-block; ${centerStyle}">${lineText}</span>`;
|
lineText = `<span style="display: inline-block; ${centerStyle}">${lineText}</span>`;
|
||||||
|
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ class TextPage extends Vue {
|
|||||||
this.parsed.p = this.p;
|
this.parsed.p = this.p;
|
||||||
this.parsed.w = this.w;// px, ширина текста
|
this.parsed.w = this.w;// px, ширина текста
|
||||||
this.parsed.font = this.font;
|
this.parsed.font = this.font;
|
||||||
|
this.parsed.fontSize = this.fontSize;
|
||||||
this.parsed.wordWrap = this.wordWrap;
|
this.parsed.wordWrap = this.wordWrap;
|
||||||
this.parsed.cutEmptyParagraphs = this.cutEmptyParagraphs;
|
this.parsed.cutEmptyParagraphs = this.cutEmptyParagraphs;
|
||||||
this.parsed.addEmptyParagraphs = this.addEmptyParagraphs;
|
this.parsed.addEmptyParagraphs = this.addEmptyParagraphs;
|
||||||
@@ -216,6 +217,9 @@ class TextPage extends Vue {
|
|||||||
while (this.drawHelper.measureText(t, {}) < this.w) t += 'Щ';
|
while (this.drawHelper.measureText(t, {}) < this.w) t += 'Щ';
|
||||||
this.parsed.maxWordLength = t.length - 1;
|
this.parsed.maxWordLength = t.length - 1;
|
||||||
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.showImages = this.showImages;
|
||||||
|
this.parsed.imageHeightLines = this.imageHeightLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
//statusBar
|
//statusBar
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ export default class BookParser {
|
|||||||
let center = false;
|
let center = false;
|
||||||
let bold = false;
|
let bold = false;
|
||||||
let italic = false;
|
let italic = false;
|
||||||
|
let space = 0;
|
||||||
|
let inPara = false;
|
||||||
|
|
||||||
this.binary = {};
|
this.binary = {};
|
||||||
let binaryId = '';
|
let binaryId = '';
|
||||||
let binaryType = '';
|
let binaryType = '';
|
||||||
@@ -147,9 +150,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)
|
||||||
|
growParagraph(`<image-inline href="${attrs.href.value}"></image-inline>`, 0);
|
||||||
|
else
|
||||||
newParagraph(`<image href="${attrs.href.value}">${' '.repeat(maxImageLineCount)}</image>`, maxImageLineCount);
|
newParagraph(`<image href="${attrs.href.value}">${' '.repeat(maxImageLineCount)}</image>`, maxImageLineCount);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (path.indexOf('/fictionbook/body') == 0) {
|
if (path.indexOf('/fictionbook/body') == 0) {
|
||||||
if (tag == 'title') {
|
if (tag == 'title') {
|
||||||
@@ -158,12 +165,18 @@ export default class BookParser {
|
|||||||
center = true;
|
center = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tag == 'section') {
|
||||||
|
newParagraph(' ', 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (tag == 'emphasis' || tag == 'strong') {
|
if (tag == 'emphasis' || tag == 'strong') {
|
||||||
growParagraph(`<${tag}>`, 0);
|
growParagraph(`<${tag}>`, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tag == 'p' || tag == 'empty-line' || tag == 'v')) {
|
if ((tag == 'p' || tag == 'empty-line' || tag == 'v')) {
|
||||||
newParagraph(' ', 1);
|
newParagraph(' ', 1);
|
||||||
|
if (tag == 'p')
|
||||||
|
inPara = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag == 'subtitle') {
|
if (tag == 'subtitle') {
|
||||||
@@ -173,6 +186,7 @@ export default class BookParser {
|
|||||||
|
|
||||||
if (tag == 'epigraph') {
|
if (tag == 'epigraph') {
|
||||||
italic = true;
|
italic = true;
|
||||||
|
space += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag == 'poem') {
|
if (tag == 'poem') {
|
||||||
@@ -180,7 +194,8 @@ export default class BookParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tag == 'text-author') {
|
if (tag == 'text-author') {
|
||||||
newParagraph(' <s> <s> <s> ', 4);
|
newParagraph(' ', 1);
|
||||||
|
space += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -201,17 +216,26 @@ export default class BookParser {
|
|||||||
growParagraph(`</${tag}>`, 0);
|
growParagraph(`</${tag}>`, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tag == 'p') {
|
||||||
|
inPara = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (tag == 'subtitle') {
|
if (tag == 'subtitle') {
|
||||||
bold = false;
|
bold = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag == 'epigraph') {
|
if (tag == 'epigraph') {
|
||||||
italic = false;
|
italic = false;
|
||||||
|
space -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag == 'stanza') {
|
if (tag == 'stanza') {
|
||||||
newParagraph(' ', 1);
|
newParagraph(' ', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tag == 'text-author') {
|
||||||
|
space -= 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
path = path.substr(0, path.length - tag.length - 1);
|
path = path.substr(0, path.length - tag.length - 1);
|
||||||
@@ -273,7 +297,9 @@ export default class BookParser {
|
|||||||
let tOpen = (center ? '<center>' : '');
|
let tOpen = (center ? '<center>' : '');
|
||||||
tOpen += (bold ? '<strong>' : '');
|
tOpen += (bold ? '<strong>' : '');
|
||||||
tOpen += (italic ? '<emphasis>' : '');
|
tOpen += (italic ? '<emphasis>' : '');
|
||||||
let tClose = (italic ? '</emphasis>' : '');
|
tOpen += (space ? `<space w="${space}">` : '');
|
||||||
|
let tClose = (space ? '</space>' : '');
|
||||||
|
tClose += (italic ? '</emphasis>' : '');
|
||||||
tClose += (bold ? '</strong>' : '');
|
tClose += (bold ? '</strong>' : '');
|
||||||
tClose += (center ? '</center>' : '');
|
tClose += (center ? '</center>' : '');
|
||||||
|
|
||||||
@@ -348,18 +374,13 @@ export default class BookParser {
|
|||||||
|
|
||||||
splitToStyle(s) {
|
splitToStyle(s) {
|
||||||
let result = [];/*array of {
|
let result = [];/*array of {
|
||||||
style: {bold: Boolean, italic: Boolean, center: Boolean},
|
style: {bold: Boolean, italic: Boolean, center: Boolean, space: Number},
|
||||||
image: Boolean,
|
image: {local: Boolean, inline: Boolean, id: String},
|
||||||
imageId: String,
|
|
||||||
text: String,
|
text: String,
|
||||||
}*/
|
}*/
|
||||||
let style = {};
|
let style = {};
|
||||||
let image = {};
|
let image = {};
|
||||||
|
|
||||||
/*let attrs = sax.getAttrsSync(tail);
|
|
||||||
if (attrs.href.value)
|
|
||||||
newParagraph(' '.repeat(maxImageLineCount) + `<image href="${attrs.href.value}" />`, maxImageLineCount);
|
|
||||||
*/
|
|
||||||
const onTextNode = async(text) => {// eslint-disable-line no-unused-vars
|
const onTextNode = async(text) => {// eslint-disable-line no-unused-vars
|
||||||
result.push({
|
result.push({
|
||||||
style: Object.assign({}, style),
|
style: Object.assign({}, style),
|
||||||
@@ -379,10 +400,43 @@ export default class BookParser {
|
|||||||
case 'center':
|
case 'center':
|
||||||
style.center = true;
|
style.center = true;
|
||||||
break;
|
break;
|
||||||
case 'image':
|
case 'space': {
|
||||||
image = {};
|
let attrs = sax.getAttrsSync(tail);
|
||||||
|
if (attrs.w.value)
|
||||||
|
style.space = attrs.w.value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'image': {
|
||||||
|
let attrs = sax.getAttrsSync(tail);
|
||||||
|
let id = attrs.href.value;
|
||||||
|
if (id) {
|
||||||
|
let local = false;
|
||||||
|
if (id[0] == '#') {
|
||||||
|
id = id.substr(1);
|
||||||
|
local = true;
|
||||||
|
}
|
||||||
|
image = {local, inline: false, id};
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'image-inline': {
|
||||||
|
let attrs = sax.getAttrsSync(tail);
|
||||||
|
let id = attrs.href.value;
|
||||||
|
if (id) {
|
||||||
|
let local = false;
|
||||||
|
if (id[0] == '#') {
|
||||||
|
id = id.substr(1);
|
||||||
|
local = true;
|
||||||
|
}
|
||||||
|
result.push({
|
||||||
|
style: Object.assign({}, style),
|
||||||
|
image: {local, inline: true, id},
|
||||||
|
text: ''
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onEndNode = async(elemName) => {// eslint-disable-line no-unused-vars
|
const onEndNode = async(elemName) => {// eslint-disable-line no-unused-vars
|
||||||
@@ -396,9 +450,14 @@ export default class BookParser {
|
|||||||
case 'center':
|
case 'center':
|
||||||
style.center = false;
|
style.center = false;
|
||||||
break;
|
break;
|
||||||
|
case 'space':
|
||||||
|
style.space = 0;
|
||||||
|
break;
|
||||||
case 'image':
|
case 'image':
|
||||||
image = {};
|
image = {};
|
||||||
break;
|
break;
|
||||||
|
case 'image-inline':
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -412,6 +471,7 @@ export default class BookParser {
|
|||||||
result = [];
|
result = [];
|
||||||
for (const part of parts) {
|
for (const part of parts) {
|
||||||
let p = part;
|
let p = part;
|
||||||
|
if (!p.image.id) {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
let spaceIndex = -1;
|
let spaceIndex = -1;
|
||||||
while (i < p.text.length) {
|
while (i < p.text.length) {
|
||||||
@@ -421,12 +481,13 @@ export default class BookParser {
|
|||||||
if (i - spaceIndex >= maxWordLength && i < p.text.length - 1 &&
|
if (i - spaceIndex >= maxWordLength && i < p.text.length - 1 &&
|
||||||
this.measureText(p.text.substr(spaceIndex + 1, i - spaceIndex), p.style) >= this.w - this.p) {
|
this.measureText(p.text.substr(spaceIndex + 1, i - spaceIndex), p.style) >= this.w - this.p) {
|
||||||
result.push({style: p.style, image: p.image, text: p.text.substr(0, i + 1)});
|
result.push({style: p.style, image: p.image, text: p.text.substr(0, i + 1)});
|
||||||
p = {style: p.style, text: p.text.substr(i + 1)};
|
p = {style: p.style, image: p.image, text: p.text.substr(i + 1)};
|
||||||
spaceIndex = -1;
|
spaceIndex = -1;
|
||||||
i = -1;
|
i = -1;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
result.push(p);
|
result.push(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,7 +555,9 @@ export default class BookParser {
|
|||||||
para.parsed.maxWordLength === this.maxWordLength &&
|
para.parsed.maxWordLength === this.maxWordLength &&
|
||||||
para.parsed.font === this.font &&
|
para.parsed.font === this.font &&
|
||||||
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.imageHeightLines === this.imageHeightLines
|
||||||
)
|
)
|
||||||
return para.parsed;
|
return para.parsed;
|
||||||
|
|
||||||
@@ -506,6 +569,8 @@ export default class BookParser {
|
|||||||
font: this.font,
|
font: this.font,
|
||||||
cutEmptyParagraphs: this.cutEmptyParagraphs,
|
cutEmptyParagraphs: this.cutEmptyParagraphs,
|
||||||
addEmptyParagraphs: this.addEmptyParagraphs,
|
addEmptyParagraphs: this.addEmptyParagraphs,
|
||||||
|
showImages: this.showImages,
|
||||||
|
imageHeightLines: this.imageHeightLines,
|
||||||
visible: !(
|
visible: !(
|
||||||
(this.cutEmptyParagraphs && para.cut) ||
|
(this.cutEmptyParagraphs && para.cut) ||
|
||||||
(para.addIndex > this.addEmptyParagraphs)
|
(para.addIndex > this.addEmptyParagraphs)
|
||||||
@@ -521,6 +586,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},
|
||||||
text: String,
|
text: String,
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
@@ -531,16 +597,58 @@ export default class BookParser {
|
|||||||
|
|
||||||
let str = '';//измеряемая строка
|
let str = '';//измеряемая строка
|
||||||
let prevStr = '';//строка без крайнего слова
|
let prevStr = '';//строка без крайнего слова
|
||||||
let prevW = 0;
|
|
||||||
let j = 0;//номер строки
|
let j = 0;//номер строки
|
||||||
let style = {};
|
let style = {};
|
||||||
let ofs = 0;//смещение от начала параграфа para.offset
|
let ofs = 0;//смещение от начала параграфа para.offset
|
||||||
|
let imgW = 0;
|
||||||
|
|
||||||
// тут начинается самый замес, перенос по слогам и стилизация
|
// тут начинается самый замес, перенос по слогам и стилизация, а также изображения
|
||||||
for (const part of parts) {
|
for (const part of parts) {
|
||||||
const words = part.text.split(' ');
|
|
||||||
style = part.style;
|
style = part.style;
|
||||||
|
|
||||||
|
//изображения
|
||||||
|
if (part.image.id && !part.image.inline) {
|
||||||
|
parsed.visible = this.showImages;
|
||||||
|
const bin = this.binary[part.image.id];
|
||||||
|
|
||||||
|
let lineCount = this.imageHeightLines;
|
||||||
|
const c = Math.ceil(bin.h/this.lineHeight);
|
||||||
|
lineCount = (c < lineCount ? c : lineCount);
|
||||||
|
let i = 0;
|
||||||
|
for (; i < lineCount - 1; i++) {
|
||||||
|
line.end = para.offset + ofs;
|
||||||
|
line.first = (j == 0);
|
||||||
|
line.last = false;
|
||||||
|
line.parts.push({style, text: ' ', image: {
|
||||||
|
local: part.image.local,
|
||||||
|
inline: false,
|
||||||
|
id: part.image.id,
|
||||||
|
imageLine: i,
|
||||||
|
lineCount,
|
||||||
|
paraIndex
|
||||||
|
}});
|
||||||
|
lines.push(line);
|
||||||
|
line = {begin: line.end + 1, parts: []};
|
||||||
|
ofs++;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
line.first = (j == 0);
|
||||||
|
line.last = true;
|
||||||
|
line.parts.push({style, text: ' ',
|
||||||
|
image: {local: part.image.local, inline: false, id: part.image.id, imageLine: i, lineCount, paraIndex}});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (part.image.id && part.image.inline && this.showImages) {
|
||||||
|
const bin = this.binary[part.image.id];
|
||||||
|
let imgH = (bin.h > this.fontSize ? this.fontSize : bin.h);
|
||||||
|
imgW += bin.w*imgH/bin.h;
|
||||||
|
line.parts.push({style, text: '',
|
||||||
|
image: {local: part.image.local, inline: true, id: part.image.id}});
|
||||||
|
}
|
||||||
|
|
||||||
|
let words = part.text.split(' ');
|
||||||
|
|
||||||
let sp1 = '';
|
let sp1 = '';
|
||||||
let sp2 = '';
|
let sp2 = '';
|
||||||
for (let i = 0; i < words.length; i++) {
|
for (let i = 0; i < words.length; i++) {
|
||||||
@@ -552,7 +660,8 @@ export default class BookParser {
|
|||||||
|
|
||||||
str += sp1 + word;
|
str += sp1 + word;
|
||||||
|
|
||||||
let p = (j == 0 ? parsed.p : 0);
|
let p = (j == 0 ? parsed.p : 0) + imgW;
|
||||||
|
p = (style.space ? p + parsed.p*style.space : p);
|
||||||
let w = this.measureText(str, style) + p;
|
let w = this.measureText(str, style) + p;
|
||||||
let wordTail = word;
|
let wordTail = word;
|
||||||
if (w > parsed.w && prevStr != '') {
|
if (w > parsed.w && prevStr != '') {
|
||||||
@@ -578,7 +687,6 @@ export default class BookParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pw) {
|
if (pw) {
|
||||||
prevW = pw;
|
|
||||||
partText += ss + (ss[ss.length - 1] == '-' ? '' : '-');
|
partText += ss + (ss[ss.length - 1] == '-' ? '' : '-');
|
||||||
wordTail = slogi.join('');
|
wordTail = slogi.join('');
|
||||||
}
|
}
|
||||||
@@ -592,7 +700,6 @@ export default class BookParser {
|
|||||||
let t = line.parts[line.parts.length - 1].text;
|
let t = line.parts[line.parts.length - 1].text;
|
||||||
if (t[t.length - 1] == ' ') {
|
if (t[t.length - 1] == ' ') {
|
||||||
line.parts[line.parts.length - 1].text = t.trimRight();
|
line.parts[line.parts.length - 1].text = t.trimRight();
|
||||||
prevW -= this.measureText(' ', style);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -600,7 +707,6 @@ export default class BookParser {
|
|||||||
if (line.end - line.begin < 0)
|
if (line.end - line.begin < 0)
|
||||||
console.error(`Parse error, empty line in paragraph ${paraIndex}`);
|
console.error(`Parse error, empty line in paragraph ${paraIndex}`);
|
||||||
|
|
||||||
line.width = prevW;
|
|
||||||
line.first = (j == 0);
|
line.first = (j == 0);
|
||||||
line.last = false;
|
line.last = false;
|
||||||
lines.push(line);
|
lines.push(line);
|
||||||
@@ -609,6 +715,7 @@ export default class BookParser {
|
|||||||
partText = '';
|
partText = '';
|
||||||
sp2 = '';
|
sp2 = '';
|
||||||
str = wordTail;
|
str = wordTail;
|
||||||
|
imgW = 0;
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,7 +723,6 @@ export default class BookParser {
|
|||||||
partText += sp2 + wordTail;
|
partText += sp2 + wordTail;
|
||||||
sp1 = ' ';
|
sp1 = ' ';
|
||||||
sp2 = ' ';
|
sp2 = ' ';
|
||||||
prevW = w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (partText != '')
|
if (partText != '')
|
||||||
@@ -628,14 +734,12 @@ export default class BookParser {
|
|||||||
let t = line.parts[line.parts.length - 1].text;
|
let t = line.parts[line.parts.length - 1].text;
|
||||||
if (t[t.length - 1] == ' ') {
|
if (t[t.length - 1] == ' ') {
|
||||||
line.parts[line.parts.length - 1].text = t.trimRight();
|
line.parts[line.parts.length - 1].text = t.trimRight();
|
||||||
prevW -= this.measureText(' ', style);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
line.end = para.offset + para.length - 1;
|
line.end = para.offset + para.length - 1;
|
||||||
if (line.end - line.begin < 0)
|
if (line.end - line.begin < 0)
|
||||||
console.error(`Parse error, empty line in paragraph ${paraIndex}`);
|
console.error(`Parse error, empty line in paragraph ${paraIndex}`);
|
||||||
|
|
||||||
line.width = prevW;
|
|
||||||
line.first = (j == 0);
|
line.first = (j == 0);
|
||||||
line.last = true;
|
line.last = true;
|
||||||
lines.push(line);
|
lines.push(line);
|
||||||
|
|||||||
@@ -163,6 +163,8 @@ const settingDefaults = {
|
|||||||
cutEmptyParagraphs: false,
|
cutEmptyParagraphs: false,
|
||||||
addEmptyParagraphs: 0,
|
addEmptyParagraphs: 0,
|
||||||
blinkCachedLoad: true,
|
blinkCachedLoad: true,
|
||||||
|
showImages: true,
|
||||||
|
imageHeightLines: 100,
|
||||||
|
|
||||||
fontShifts: {},
|
fontShifts: {},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
siteroot = 'http://omnireader.ru:11080/';
|
siteroot = 'http://old.omnireader.ru/';
|
||||||
doRedirect = '';
|
doRedirect = '';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
$siteroot = 'http://omnireader.ru:11080/';
|
$siteroot = 'http://old.omnireader.ru/';
|
||||||
$use_gzip = false;
|
$use_gzip = false;
|
||||||
$tmp_dir = '/tmp';
|
$tmp_dir = '/tmp';
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -156,7 +156,7 @@
|
|||||||
Ïîääåðæèâàåìûå ôîðìàòû: <strong>html, txt, fb2, fb2.zip</strong>
|
Ïîääåðæèâàåìûå ôîðìàòû: <strong>html, txt, fb2, fb2.zip</strong>
|
||||||
|
|
||||||
<br><br>Âû ìîæåòå äîáàâèòü â ñâîé áðàóçåð çàêëàäêó, óêàçàâ â åå ñâîéñòâàõ âìåñòî àäðåñà ñëåäóþùèé êîä:
|
<br><br>Âû ìîæåòå äîáàâèòü â ñâîé áðàóçåð çàêëàäêó, óêàçàâ â åå ñâîéñòâàõ âìåñòî àäðåñà ñëåäóþùèé êîä:
|
||||||
<br><p><strong>javascript:location.href='http://omnireader.ru:11080/?url='+location.href;</strong>
|
<br><p><strong>javascript:location.href='http://old.omnireader.ru/?url='+location.href;</strong>
|
||||||
<br>Òîãäà, íàæàâ íà ïîëó÷èâøóþñÿ êíîïêó íà ëþáîé ñòðàíèöå èíòåðíåòà, âû àâòîìàòè÷åñêè îòêðîåòå åå â Omni Reader.
|
<br>Òîãäà, íàæàâ íà ïîëó÷èâøóþñÿ êíîïêó íà ëþáîé ñòðàíèöå èíòåðíåòà, âû àâòîìàòè÷åñêè îòêðîåòå åå â Omni Reader.
|
||||||
|
|
||||||
<br><br>Äëÿ Chrome íà Android ìîæíî âûçûâàòü çàêëàäêó ïî åå èìåíè (èìÿ ñòîèò ñäåëàòü ïîïðîùå) â àäðåñíîé ñòðîêå áðàóçåðà, ïîñêîëüêó ñòàíäàðòíûé âûçîâ òàêîé çàêëàäêè íå ðàáîòàåò.
|
<br><br>Äëÿ Chrome íà Android ìîæíî âûçûâàòü çàêëàäêó ïî åå èìåíè (èìÿ ñòîèò ñäåëàòü ïîïðîùå) â àäðåñíîé ñòðîêå áðàóçåðà, ïîñêîëüêó ñòàíäàðòíûé âûçîâ òàêîé çàêëàäêè íå ðàáîòàåò.
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 11080;
|
listen 80;
|
||||||
server_name omnireader.ru;
|
server_name old.omnireader.ru;
|
||||||
|
|
||||||
client_max_body_size 50m;
|
client_max_body_size 50m;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Liberama",
|
"name": "Liberama",
|
||||||
"version": "0.3.3",
|
"version": "0.4.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.0.0"
|
"node": ">=10.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user