SemanticMediaWiki / Mermaid

Provides a parser function to generate diagrams and flowcharts with the help of the mermaid script language
https://www.mediawiki.org/wiki/Extension:Mermaid
Other
36 stars 22 forks source link

Mermaid does not load when used within a Flow topic #52

Open bitsofmymind opened 3 years ago

bitsofmymind commented 3 years ago

Setup and configuration

Issue

This is a bit of a corner case, but we've found out that Mermaid does not load when called within a Flow (StructuredDiscussions) topic. The syntax does not work standalone and needs to be wrapped in a Template, but that's probably a Flow issue.

However, when wrapped in a Template and called from a Flow topic, the mermaid librairies are not loaded.

Adding the following to Mediawiki:Common.js seems to get it to work:

if(mw.config.get('wgNamespaceNumber') % 2 && $('.ext-mermaid').length) 
{ 
    var config = mw.config.get( 'mermaid' );
    mw.loader.using( [ 'mediawiki.api', 'ext.mermaid', 'ext.mermaid.theme.' + config.theme ] );
 }
kghbln commented 3 years ago

Thanks for reporting and suggesting a fix. You can create a pull if you like.

kghbln commented 3 years ago

@JeroenDeDauw This suggests adding something to common.js Probably a solution could be added to Mermaid code itself. Something to integrate into 3.0.0 (#48) though not a blocker

JeroenDeDauw commented 3 years ago

This looks like a bug, not like a breaking change, so I do not feel in any way compelled to work on this by 3.0 release

kghbln commented 3 years ago

This looks like a bug, not like a breaking change, so I do not feel in any way compelled to work on this by 3.0 release

No worries. That's why I mentioned: though not a blocker.

bitsofmymind commented 3 years ago

Thank you gents,

In fact, the proposed solutions works "most of the time" but sometimes doesn't, which leads me to believe that it browser timing sensitive. In short, it's an ugly hack.

The problem indeed seems to lie with the Flow extension. I figured I'd report it in case someone came up with a better fix.

kghbln commented 3 years ago

In fact, the proposed solutions works "most of the time" but sometimes doesn't, which leads me to believe that it browser timing sensitive. In short, it's an ugly hack.

Still much better than nothing and great that you shared this interim solution.

The problem indeed seems to lie with the Flow extension. I figured I'd report it in case someone came up with a better fix.

I suspect this is may very well be the case. Keeping fingers crossed since development for Flow has basically been reduced to hot fixes only afaik.