From 31da2f590f4e87bf9673589a6bb2e8def8dde263 Mon Sep 17 00:00:00 2001 From: axolotle Date: Thu, 29 Jul 2021 14:56:07 +0200 Subject: [PATCH] fix footnotes --- src/components/nodes/NodeViewBody.vue | 75 ++++++++++++++++---------- src/components/nodes/NodeViewTitle.vue | 5 +- src/store/nodes.js | 6 ++- 3 files changed, 55 insertions(+), 31 deletions(-) diff --git a/src/components/nodes/NodeViewBody.vue b/src/components/nodes/NodeViewBody.vue index 0eb5168..c7335b3 100644 --- a/src/components/nodes/NodeViewBody.vue +++ b/src/components/nodes/NodeViewBody.vue @@ -14,32 +14,34 @@ - -
+
@@ -76,7 +78,7 @@ export default { const number = parseInt(link.hash.replace('#', '')) if (!isNaN(number)) { link.classList.add('footnote-link') - link.id = 'note-' + number + link.id = `note-${this.node.id}-${number}` link.innerHTML = link.textContent if (link.parentElement.nodeName === 'SUP') { link.parentElement.replaceWith(link) @@ -86,6 +88,19 @@ export default { }) }, + hideFootnotes () { + const links = this.$el.querySelectorAll('a') + links.forEach((link, i) => { + const number = parseInt(link.hash.replace('#', '')) + if (!isNaN(number)) { + link.classList.add('footnote-link') + if (link.parentElement.nodeName === 'SUP') { + link.parentElement.replaceWith(link) + } + } + }) + }, + mountMedias () { const template = document.getElementById('expand-image-tmp') this.$el.querySelectorAll('.node-view-body-wrapper img').forEach(img => { @@ -123,10 +138,10 @@ export default { mounted () { if (this.mode === 'view') { - if (this.node.notes) { - this.addFootnotes() - } + this.addFootnotes() this.mountMedias() + } else { + this.hideFootnotes() } } } @@ -202,6 +217,10 @@ export default { max-height: 1.4em; margin: 0 .2em; } + + &-card .footnote-link { + display: none; + } } .footnote { diff --git a/src/components/nodes/NodeViewTitle.vue b/src/components/nodes/NodeViewTitle.vue index a6bb445..ea23e94 100644 --- a/src/components/nodes/NodeViewTitle.vue +++ b/src/components/nodes/NodeViewTitle.vue @@ -6,7 +6,7 @@ > @@ -55,8 +55,9 @@ export default { trim, toCommaList, - onTitleClick (node) { + onTitleClick (e) { if (this.link) { + e.stopPropagation() this.$emit('open-node') } } diff --git a/src/store/nodes.js b/src/store/nodes.js index 0de2915..86b50af 100644 --- a/src/store/nodes.js +++ b/src/store/nodes.js @@ -175,6 +175,10 @@ export default { nodes: state => ids => ids.map(id => state.nodes[id]), node: state => id => state.nodes[id], optionsVisible: state => state.optionsVisible, - history: state => state.history.map(id => state.nodes[id]) + history: state => { + return state.history.map(id => state.nodes[id]).filter(node => { + return node.dataLevel > 0 + }) + } } }