Fixed orphaned markdown elements

This commit is contained in:
Magnus Åhall 2024-01-09 17:15:05 +01:00
parent 1e42be3a4b
commit 02c427da23

View File

@ -311,7 +311,7 @@ class NodeContent extends Component {
var element var element
if (node.RenderMarkdown.value) if (node.RenderMarkdown.value)
element = html`<div id="markdown"></div>` element = html`<${MarkdownContent} key='markdown-content' content=${content} />`
else else
element = html` element = html`
<div class="grow-wrap"> <div class="grow-wrap">
@ -322,18 +322,10 @@ class NodeContent extends Component {
return element return element
}//}}} }//}}}
componentDidMount() {//{{{ componentDidMount() {//{{{
const markdown = document.getElementById('markdown')
if (markdown)
markdown.innerHTML = marked.parse(this.props.node.content())
this.resize() this.resize()
window.addEventListener('resize', () => this.resize()) window.addEventListener('resize', () => this.resize())
}//}}} }//}}}
componentDidUpdate() {//{{{ componentDidUpdate() {//{{{
const markdown = document.getElementById('markdown')
if (markdown)
markdown.innerHTML = marked.parse(this.props.node.content())
this.resize() this.resize()
}//}}} }//}}}
contentChanged(evt) {//{{{ contentChanged(evt) {//{{{
@ -371,6 +363,17 @@ class NodeContent extends Component {
}//}}} }//}}}
} }
class MarkdownContent extends Component {
render({ content }) {
return html`<div id="markdown"></div>`
}
componentDidMount() {//{{{
const markdown = document.getElementById('markdown')
if (markdown)
markdown.innerHTML = marked.parse(this.props.content)
}//}}}
}
class NodeFiles extends Component { class NodeFiles extends Component {
render({ node }) {//{{{ render({ node }) {//{{{
if (node.Files === null || node.Files.length == 0) if (node.Files === null || node.Files.length == 0)