1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-24 08:12:24 +02:00

Desktop: Fixes #4612: Fix mermaid diagrams in WYSIWYG editor (#4670)

This commit is contained in:
mbalint 2021-03-15 17:31:11 +01:00 committed by GitHub
parent e954ecd024
commit e81c7f2dd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,10 +24,14 @@ export default {
const token = tokens[idx];
if (token.info !== 'mermaid') return defaultRender(tokens, idx, options, env, self);
const contentHtml = markdownIt.utils.escapeHtml(token.content);
// Note: The mermaid script (`contentHtml`) needs to be wrapped
// in a `pre` tag, otherwise in WYSIWYG mode TinyMCE removes
// all the white space from it, which causes mermaid to fail.
// See PR #4670 https://github.com/laurent22/joplin/pull/4670
return `
<div class="joplin-editable">
<pre class="joplin-source" data-joplin-language="mermaid" data-joplin-source-open="\`\`\`mermaid&#10;" data-joplin-source-close="&#10;\`\`\`&#10;">${contentHtml}</pre>
<div class="mermaid">${contentHtml}</div>
<pre class="mermaid">${contentHtml}</pre>
</div>
`;
};