diff --git a/client/components/Reader/TextPage/DrawHelper.js b/client/components/Reader/TextPage/DrawHelper.js index 2bcf2583..f3bf9e77 100644 --- a/client/components/Reader/TextPage/DrawHelper.js +++ b/client/components/Reader/TextPage/DrawHelper.js @@ -39,6 +39,7 @@ export default class DrawHelper { let center = false; let space = 0; let j = 0; + const pad = this.fontSize/2; //формируем строку for (const part of line.parts) { let tOpen = ''; @@ -46,7 +47,12 @@ export default class DrawHelper { tOpen += (part.style.italic ? '' : ''); tOpen += (part.style.sup ? '' : ''); tOpen += (part.style.sub ? '' : ''); + tOpen += (part.style.note ? `` + + `` : ''); let tClose = ''; + tClose += (part.style.note ? '' : ''); tClose += (part.style.sub ? '' : ''); tClose += (part.style.sup ? '' : ''); tClose += (part.style.italic ? '' : ''); @@ -64,6 +70,9 @@ export default class DrawHelper { if (text && text.trim() == '') text = `${text}`; + if (part.style.note) + tOpen = tOpen.replace('__TEXT', text); + lineText += `${tOpen}${text}${tClose}`; center = center || part.style.center; diff --git a/client/components/Reader/TextPage/TextPage.vue b/client/components/Reader/TextPage/TextPage.vue index 5568a501..fd393296 100644 --- a/client/components/Reader/TextPage/TextPage.vue +++ b/client/components/Reader/TextPage/TextPage.vue @@ -4,12 +4,12 @@
-${p}
`).join(''); + this.noteDialogVisible = true; + } else {//go to orig + this.goToOrigNote(noteId); + } + } + } + + goToNotes() { + const note = this.parsed.notes[this.noteId]; + if (note && note.noteParaIndex >= 0) { + + const para = this.parsed.parsePara(note.noteParaIndex); + + this.userBookPosChange = true; + this.bookPos = para.lines[0].begin; + + this.noteDialogVisible = false; + } + } + + goToOrigNote(noteId) { + const note = this.parsed.notes[noteId]; + if (note && note.noteParaIndex >= 0) { + + const para = this.parsed.parsePara(note.linkParaIndex); + + this.userBookPosChange = true; + this.bookPos = para.lines[0].begin; + + this.noteDialogVisible = false; + } + } } export default vueComponent(TextPage); @@ -1244,7 +1324,7 @@ export default vueComponent(TextPage); } .events { - z-index: 20; + z-index: 9; background-color: rgba(0,0,0,0); } diff --git a/client/components/Reader/share/BookParser.js b/client/components/Reader/share/BookParser.js index cfceea3e..54f6236d 100644 --- a/client/components/Reader/share/BookParser.js +++ b/client/components/Reader/share/BookParser.js @@ -86,17 +86,23 @@ export default class BookParser { let binaryType = ''; let dimPromises = []; this.coverPageId = ''; + this.images = []; + let imageNum = 0; + + //примечания + this.notes = {}; + let inNote = false; + let noteId = ''; + let inNotesBody = false; //оглавление this.contents = []; - this.images = []; let curTitle = {paraIndex: -1, title: '', subtitles: []}; let curSubtitle = {paraIndex: -1, title: ''}; let inTitle = false; let inSubtitle = false; let sectionLevel = 0; let bodyIndex = 0; - let imageNum = 0; let paraIndex = -1; let paraOffset = 0; @@ -289,7 +295,7 @@ export default class BookParser { 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); + const {id, local} = this.hrefToId(href); if (local) {//local imageNum++; @@ -322,6 +328,23 @@ export default class BookParser { } } + if (tag == 'a') { + let attrs = sax.getAttrsSync(tail); + if (attrs.href && attrs.href.value && attrs.type && attrs.type.value === 'note') {//note + const href = attrs.href.value; + const {id, local} = this.hrefToId(href); + + if (local) { + inNote = true; + growParagraph(`').filter(v => v).map(v => utils.removeHtmlTags(v));
ann.forEach(a => {
@@ -389,6 +417,23 @@ export default class BookParser {
newParagraph();
isFirstSection = false;
sectionLevel++;
+
+ if (inNotesBody) {
+ let attrs = sax.getAttrsSync(tail);
+ if (attrs.id && attrs.id.value) {//notes
+ const id = attrs.id.value;
+ let note = this.notes[id];
+ if (!note) {
+ note = {id};
+ this.notes[id] = note;
+ }
+
+ note.noteParaIndex = paraIndex;
+ note.para = [];
+ noteId = id;
+ }
+
+ }
}
if (tag == 'emphasis' || tag == 'strong' || tag == 'sup' || tag == 'sub') {
@@ -401,6 +446,14 @@ export default class BookParser {
if (tag == 'p') {
inPara = true;
isFirstTitlePara = false;
+
+ if (inNotesBody && noteId) {
+ if (!inTitle) {
+ this.notes[noteId].para.push('');
+ } else {
+ growParagraph(`