Добавлен парсинг оглавления из djvu, добавлено отображение атрибута alt изображений в ContentsPage

This commit is contained in:
Book Pauk
2020-12-17 20:57:29 +07:00
parent 9492f85d80
commit f5c06ce420
4 changed files with 43 additions and 11 deletions

View File

@@ -67,6 +67,7 @@
<img v-show="imageLoaded[item.id]" class="image-thumb" :src="imageSrc[item.id]"/>
</div>
<div class="no-expand-button column justify-center items-center">
<div class="image-num">{{ item.num }}</div>
<div v-show="item.type == 'image/jpeg'" class="image-type it-jpg-color row justify-center">JPG</div>
<div v-show="item.type == 'image/png'" class="image-type it-png-color row justify-center">PNG</div>
<div v-show="!item.local" class="image-type it-net-color row justify-center">INET</div>
@@ -218,13 +219,13 @@ class ContentsPage extends ContentsPageProps {
const bin = parsed.binary[image.id];
const type = (bin ? bin.type : '');
const label = `Изображение ${image.num}`;
const label = (image.alt ? image.alt : '<span style="font-size: 90%; color: #dddddd"><i>Без названия</i></span>');
const indentStyle = getIndentStyle(1);
const labelStyle = getLabelStyle(0);
const p = parsed.para[image.paraIndex];
newImages.push({perc: (p.offset/parsed.textLength*100).toFixed(0), label, key: i, offset: p.offset,
indentStyle, labelStyle, type, id: image.id, local: image.local});
indentStyle, labelStyle, type, num: image.num, id: image.id, local: image.local});
}
this.images = newImages;
@@ -389,6 +390,10 @@ class ContentsPage extends ContentsPageProps {
transform: rotate(90deg);
}
.image-num {
font-size: 120%;
padding-bottom: 3px;
}
.image-type {
border: 1px solid black;
border-radius: 6px;

View File

@@ -205,6 +205,7 @@ export default class BookParser {
let attrs = sax.getAttrsSync(tail);
if (attrs.href && attrs.href.value) {
const href = attrs.href.value;
const alt = (attrs.alt && attrs.alt.value ? attrs.alt.value : '');
const {id, local} = this.imageHrefToId(href);
if (href[0] == '#') {//local
imageNum++;
@@ -214,7 +215,7 @@ export default class BookParser {
else
newParagraph(`<image href="${href}" num="${imageNum}">${' '.repeat(maxImageLineCount)}</image>`, maxImageLineCount);
this.images.push({paraIndex, num: imageNum, id, local});
this.images.push({paraIndex, num: imageNum, id, local, alt});
if (inPara && this.showInlineImagesInCenter)
newParagraph(' ', 1);
@@ -224,7 +225,7 @@ export default class BookParser {
dimPromises.push(getExternalImageDimensions(href));
newParagraph(`<image href="${href}" num="${imageNum}">${' '.repeat(maxImageLineCount)}</image>`, maxImageLineCount);
this.images.push({paraIndex, num: imageNum, id, local});
this.images.push({paraIndex, num: imageNum, id, local, alt});
}
}
}