Поправки по результату тестирования
This commit is contained in:
@@ -22,6 +22,7 @@ const defaultSettings = {
|
||||
imageFitWidth: true, //ширина изображения не более ширины страницы
|
||||
compactTextPerc: 0, //проценты, степень компактности текста
|
||||
testWidth: 0, //ширина тестовой строки, пересчитывается извне при изменении шрифта браузером
|
||||
isTesting: false, //тестовый режим
|
||||
|
||||
//заглушка, измеритель ширины текста
|
||||
measureText: (text, style) => {// eslint-disable-line no-unused-vars
|
||||
@@ -243,6 +244,7 @@ export default class BookParser {
|
||||
} else {//external
|
||||
imageNum++;
|
||||
|
||||
if (!this.sets.isTesting)
|
||||
dimPromises.push(getExternalImageDimensions(href));
|
||||
newParagraph(`<image href="${href}" num="${imageNum}">${' '.repeat(maxImageLineCount)}</image>`, maxImageLineCount);
|
||||
|
||||
@@ -490,7 +492,7 @@ export default class BookParser {
|
||||
growParagraph(`${tOpen}${text}${tClose}`, text.length);
|
||||
}
|
||||
|
||||
if (binaryId) {
|
||||
if (binaryId && !this.sets.isTesting) {
|
||||
dimPromises.push(getImageDimensions(binaryId, binaryType, text));
|
||||
}
|
||||
};
|
||||
@@ -563,9 +565,19 @@ export default class BookParser {
|
||||
let style = {};
|
||||
let image = {};
|
||||
|
||||
//оптимизация по памяти
|
||||
const copyStyle = (s) => {
|
||||
const r = {};
|
||||
for (const prop in s) {
|
||||
if (s[prop])
|
||||
r[prop] = s[prop];
|
||||
}
|
||||
return r;
|
||||
};
|
||||
|
||||
const onTextNode = async(text) => {// eslint-disable-line no-unused-vars
|
||||
result.push({
|
||||
style: Object.assign({}, style),
|
||||
style: copyStyle(style),
|
||||
image,
|
||||
text
|
||||
});
|
||||
@@ -610,7 +622,7 @@ export default class BookParser {
|
||||
img.inline = true;
|
||||
img.num = (attrs.num && attrs.num.value ? attrs.num.value : 0);
|
||||
result.push({
|
||||
style: Object.assign({}, style),
|
||||
style: copyStyle(style),
|
||||
image: img,
|
||||
text: ''
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user