1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Fix to replace only CodeBlock

This commit is contained in:
asmsuechan
2017-03-19 15:26:43 -07:00
parent f7e0cb655f
commit e60a5430b4

View File

@@ -258,7 +258,15 @@ export default class MarkdownPreview extends React.Component {
let { value, theme, indentSize, codeBlockTheme } = this.props
this.refs.root.contentWindow.document.body.setAttribute('data-theme', theme)
this.refs.root.contentWindow.document.body.innerHTML = markdown.render(encodeHTMLEntities(value))
const codeBlocks = value.match(/(```)(.|[\n])*?(```)/g)
if (codeBlocks.length > 0) {
codeBlocks.forEach((codeBlock) => {
const encodedCodeBlock = encodeHTMLEntities(codeBlock)
value = value.replace(codeBlock, encodedCodeBlock)
})
}
this.refs.root.contentWindow.document.body.innerHTML = markdown.render(value)
_.forEach(this.refs.root.contentWindow.document.querySelectorAll('.taskListItem'), (el) => {
el.parentNode.parentNode.style.listStyleType = 'none'