diff --git a/packages/app-mobile/pluginAssets/index.js b/packages/app-mobile/pluginAssets/index.js index 0638520a0..c7b6d4f76 100644 --- a/packages/app-mobile/pluginAssets/index.js +++ b/packages/app-mobile/pluginAssets/index.js @@ -1,5 +1,5 @@ module.exports = { -hash:"6cf170562f87803f3d6b9455bc66ccc9", files: { +hash:"d4cb80ea030d8b01caeb56299491f244", files: { 'highlight.js/atom-one-dark-reasonable.css': { data: require('./highlight.js/atom-one-dark-reasonable.css.base64.js'), mime: 'text/css', encoding: 'base64' }, 'highlight.js/atom-one-light.css': { data: require('./highlight.js/atom-one-light.css.base64.js'), mime: 'text/css', encoding: 'base64' }, 'katex/fonts/KaTeX_AMS-Regular.woff2': { data: require('./katex/fonts/KaTeX_AMS-Regular.woff2.base64.js'), mime: 'application/octet-stream', encoding: 'base64' }, diff --git a/packages/app-mobile/pluginAssets/mermaid/mermaid_render.js.base64.js b/packages/app-mobile/pluginAssets/mermaid/mermaid_render.js.base64.js index d5e80dcdd..bf1535415 100644 --- a/packages/app-mobile/pluginAssets/mermaid/mermaid_render.js.base64.js +++ b/packages/app-mobile/pluginAssets/mermaid/mermaid_render.js.base64.js @@ -1 +1 @@ -module.exports = `LyogZ2xvYmFsIG1lcm1haWQgKi8KCmZ1bmN0aW9uIG1lcm1haWRSZWFkeSgpIHsKCS8vIFRoZSBNZXJtYWlkIGluaXRpYWxpemF0aW9uIGNvZGUgcmVuZGVycyB0aGUgTWVybWFpZCBjb2RlIHdpdGhpbiBhbnkgZWxlbWVudCB3aXRoIGNsYXNzICJtZXJtYWlkIiBvcgoJLy8gSUQgIm1lcm1haWQiLiBIb3dldmVyIGluIHNvbWUgY2FzZXMgc29tZSBlbGVtZW50cyBtaWdodCBoYXZlIHRoaXMgSUQgYnV0IG5vdCBiZSBNZXJtYWlkIGNvZGUuCgkvLyBGb3IgZXhhbXBsZSwgTWFya2Rvd24gY29kZSBsaWtlIHRoaXM6CgkvLwoJLy8gICAgICMgTWVybWFpZAoJLy8KCS8v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ff --git a/packages/renderer/MdToHtml/rules/mermaid.ts b/packages/renderer/MdToHtml/rules/mermaid.ts index 5b26699ca..abae6869e 100644 --- a/packages/renderer/MdToHtml/rules/mermaid.ts +++ b/packages/renderer/MdToHtml/rules/mermaid.ts @@ -11,7 +11,7 @@ export default { // Note: Mermaid is buggy when rendering below a certain width (500px?) // so set an arbitrarily high width here for the container. Once the // diagram is rendered it will be reset to 100% in mermaid_render.js - text: '.mermaid { background-color: white; width: 640px; }', + text: '.mermaid { width: 640px; }', mime: 'text/css', }, { @@ -40,6 +40,15 @@ export default { const token = tokens[idx]; if (token.info !== 'mermaid') return defaultRender(tokens, idx, options, env, self); const contentHtml = markdownIt.utils.escapeHtml(token.content); + + const cssClasses = ['mermaid']; + if (ruleOptions.theme.appearance === 'dark') { + // This class applies globally -- if any elements have this class, all mermaid + // elements will be rendered in dark mode. + // (See mermaid_render.js for details). + cssClasses.push('joplin--mermaid-use-dark-theme'); + } + // 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. @@ -48,7 +57,7 @@ export default {
${contentHtml}${exportButtonMarkup} -
${contentHtml}+
${contentHtml}
s to prevent Mermaid elements from having a grey background */ +.mermaid { + background-color: white; +} + /* Need to set overflow so that long tables for example are scrollable. We put it here and not in noteStyle because the desktop app handles scrolling differently at the viewer level.