fix: draw.io svgs are no longer removed with linebreaks (#2415)

This commit is contained in:
NGPixel
2020-09-12 14:05:24 -04:00
parent 02c3c66084
commit 8f6cba262f
5 changed files with 538 additions and 342 deletions

View File

@@ -300,6 +300,21 @@ const md = new MarkdownIt({
.use(mdFootnote)
.use(mdImsize)
// DOMPurify fix for draw.io
DOMPurify.addHook('uponSanitizeElement', (elm) => {
if (elm.querySelectorAll) {
const breaks = elm.querySelectorAll('foreignObject br, foreignObject p')
if (breaks && breaks.length) {
for (let i = 0; i < breaks.length; i++) {
breaks[i].parentNode.replaceChild(
document.createElement('div'),
breaks[i]
)
}
}
}
})
// ========================================
// HELPER FUNCTIONS
// ========================================
@@ -459,7 +474,9 @@ export default {
linesMap = []
// this.$store.set('editor/content', newContent)
this.processMarkers(this.cm.firstLine(), this.cm.lastLine())
this.previewHTML = DOMPurify.sanitize(md.render(newContent))
this.previewHTML = DOMPurify.sanitize(md.render(newContent), {
ADD_TAGS: ['foreignObject']
})
this.$nextTick(() => {
tabsetHelper.format()
this.renderMermaidDiagrams()