Работа над изображениями

This commit is contained in:
Book Pauk
2019-02-20 16:49:03 +07:00
parent ae3dc9b22c
commit 83fc586e03
2 changed files with 40 additions and 10 deletions

View File

@@ -349,8 +349,7 @@ export default class BookParser {
splitToStyle(s) {
let result = [];/*array of {
style: {bold: Boolean, italic: Boolean, center: Boolean},
image: Boolean,
imageId: String,
image: {local: Boolean, inline: Boolean, id: String},
text: String,
}*/
let style = {};
@@ -379,8 +378,12 @@ export default class BookParser {
let attrs = sax.getAttrsSync(tail);
let id = attrs.href.value;
if (id) {
id = id.substr(1);
image = {inline: false, id};
let local = false;
if (id[0] == '#') {
id = id.substr(1);
local = true;
}
image = {local, inline: false, id};
}
break;
}
@@ -529,7 +532,7 @@ export default class BookParser {
last: Boolean,
parts: array of {
style: {bold: Boolean, italic: Boolean, center: Boolean},
image: {inline: Boolean, id: String, imageLine: Number, lineCount: Number, resize: Boolean},
image: {local: Boolean, inline: Boolean, id: String, imageLine: Number, lineCount: Number, resize: Boolean, paraIndex: Number},
text: String,
}
}*/
@@ -560,7 +563,15 @@ export default class BookParser {
line.end = para.offset + ofs;
line.first = (j == 0);
line.last = false;
line.parts.push({style, text: '!', image: {inline: false, id: part.image.id, imageLine: i, lineCount, resize: (c > lineCount)}});
line.parts.push({style, text: ' ', image: {
local: part.image.local,
inline: false,
id: part.image.id,
imageLine: i,
lineCount,
resize: (c > lineCount),
paraIndex
}});
lines.push(line);
line = {begin: line.end + 1, parts: []};
ofs++;
@@ -568,7 +579,8 @@ export default class BookParser {
}
line.first = (j == 0);
line.last = true;
line.parts.push({style, text: '!', image: {inline: false, id: part.image.id, imageLine: i, lineCount, resize: (c > lineCount)}});
line.parts.push({style, text: ' ',
image: {local: part.image.local, inline: false, id: part.image.id, imageLine: i, lineCount, resize: (c > lineCount), paraIndex}});
continue;
}