Jump to content

Extension talk:Mermaid/Flow

About this board

Adding Wiki links in the state text of a stateDiagram-v2 diagram

6
Revansx (talkcontribs)

MW 1.39, Mermaid 3.1.0

I have the following mermaid code:

{{#mermaid: stateDiagram-v2
   state "My Organization" as myorg
   state "[[Alice]]" as myorg
}}

and my hope was that the text "[[Alice]]" would render "Alice" as a wiki link, but it does not.

I would be content to put a full hyperlink in if need be, but sadly there is no reference to adding links in the mermaid state diagram documentation at: https://mermaid.js.org/syntax/stateDiagram.html

Can this be done?

TheDJ (talkcontribs)

> Can this be done?

Not as far as I'm aware.

Bryandamon (talkcontribs)

Links are possible, but only with full URLs, see the following:

graph TD;
    A-->B;
    A-->C;
    B-->D(This is a LINK!);
    C-->D;
    click D "https://www.mediawiki.org/wiki/MediaWiki"
Revansx (talkcontribs)

@Bryandamon - Hi Bryan. Thanks, but that's only for the flowchart (i.e. "graph") mermaid charts. Here I'm asking about the "stateDiagram-v2" diagrams.

Revansx (talkcontribs)

Update

I was able to get links to work by adding an html anchor in the state description. For example:

{{#mermaid: stateDiagram-v2
   state "<a href=https://www.mediawiki.org>Mediawiki</a>" as mediawiki
   state "<a href=Main_Page>Main Page</a>" as main_page
}}

Special care must be given to make sure that the <a> property does not contain any quotes.

Note - The first state (mediawiki) provides a fully qualified external link, the second state (mainpage) is treated by the mermaid extension as a local wiki link to the main page.

w00t!

/Rich

Reply to "Adding Wiki links in the state text of a stateDiagram-v2 diagram"

Styling the states of a stateDiagram-v2 diagram

3
Revansx (talkcontribs)

MW 1.39, Mermaid 3.1.0

I have the following mermaid code in my wiki:

{{#mermaid: stateDiagram-v2
   state "My Organization" as myorg
   state "Alice" as myorg
}}

and I would like to style the state. According to: https://mermaid.js.org/syntax/stateDiagram.html I should be able to add:

classDef style1 fill:#f00

and

class myorg mystyle1

..and that should change the background of my state, however, when I try it as:

{{#mermaid: stateDiagram-v2
   state "My Organization" as myorg
   state "Alice" as myorg

   classDef style1 fill:#f00

   class myorg mystyle1
}}

..it causes the mermaid parser function to fail.

Is styling a mermaid stateDiagram-v2 diagram possible?

Bryandamon (talkcontribs)

There's a small error in your class definition (class myorg style1 vs. class myorg mystyle1), you can see a working example here. I haven't checked this using the MW extension though.

Revansx (talkcontribs)

@Bryandamon - Hi Bryan. The typo is only related to my attempt to make the example I posted generic.. My actual code is all work themed and I didn't want to post it here. So the class and classDef methods truly don't work for me.

Regardless, I was able to style them by adding the following CSS in the page (using Extension:CSS)

{{#css:
.node rect { stroke: #000!important; }

line.divider { stroke: #000!important; }

.statediagram-state > .label > foreignObject:first-child > div { width: 250px!important; }

.statediagram-state > .label > foreignObject:first-child > div > .nodeLabel { color: #fff!important; }

.statediagram-state > .label > foreignObject:not(:first-child) > div > .nodeLabel { text-align: left!important; }
}}

That actually works well!

Reply to "Styling the states of a stateDiagram-v2 diagram"

Maximum text size in diagram exceeded

1
School4schools (talkcontribs)
Reply to "Maximum text size in diagram exceeded"

Update mermaid.min.js to Version 10.x

5
Ac-fra (talkcontribs)

We are using Mediawiki 1.36 with Mermaid Extension 3.1.0, which includes Mermaid 8.14.0.


An update with jarn install did not update mermaid.min.js to newer versions.

A manual update of mermaid.min.js to Version 10.4 failed, since the JavaScript could not be loaded.


Is there a practicable way to update the included version of mermaid.min.js to current version 10.x?

Mikasa7 (talkcontribs)

Hello.

Try to use the mermaid.js file instead of mermaid.min.js. Also the variable $wgResourceLoaderDebug = true; solves the problem (but this is not so much a solution as the reason why it happens).

Tom-Wiming (talkcontribs)

@Mikasa7, can you please provide a step-by-step instruction for dummies how to upgrade to Mermaid 10.x? Would be greatly appreciated!

Or could somebody who knows how to do it create a new version of the Extension with the latest Mermaid version included?

Mikasa7 (talkcontribs)

Hello @Tom-Wiming,

To update version of mermaid.js you need to clone repository: https://github.com/SemanticMediaWiki/Mermaid

Execute the commands:

  • npx npm-check-updates -u (or manually edit package.json - change the mermaid version to the new one)
  • npm install

At execution time there may be errors related to file copying, but this is OK.

The updated version of the file will be located at:

resources/mermaid.min.js

If MediaWiki cannot load new version of the file correctly replace in extension.json row resources/mermaid.min.js with resources/mermaid.js

Afterwards you should copy file node_modules/mermaid/dist/mermaid.js to resources folder.

I hope I've been helpful

Tom-Wiming (talkcontribs)

Thanks @Mikasa7! I indeed got the copying error messages, but ignored them. Also, it didn't work with "mermaid.min.js" (the code threw an exception in the browser), but using the unpacked "mermaid.js" works.

Reply to "Update mermaid.min.js to Version 10.x"

Mediawiki 1.35 with mermaid 3.0.0 displays blank page

2
Ahmad.enisyst (talkcontribs)

I am running MW 1.35 and installed Mermaid 3.0.0 and used the following syntax from example, A blank page is rendered, i also tried using the dev-master instead of 3.0.0 still nothing, i tried version 2.2.0, and then there is just a loading gif :

{{#mermaid:sequenceDiagram participant Alice participant Bob

 Alice->John: Hello John, how are you?
 loop Healthcheck
      John->John: Fight against hypochondria
 end
 Note right of John: Rational thoughts 
prevail...
   John-->Alice: Great!
   John->Bob: How about you?
   Bob-->John: Jolly good!

}}

Frosty9191 (talkcontribs)

I'm getting the same issue, lots of loading gifs and blanks.

Reply to "Mediawiki 1.35 with mermaid 3.0.0 displays blank page"

Getting "...\mediawiki\extensions\Mermaid\src\ServiceWiring.php: Class 'Mermaid\Config' not found"

2
Javier.Farachi (talkcontribs)

HI! After installing Mermaid extension, tried include this in a page:


{{#mermaid:sequenceDiagram participant Alice participant Bob

 Alice->John: Hello John, how are you?
 loop Healthcheck
      John->John: Fight against hypochondria
 end
 Note right of John: Rational thoughts 
prevail...
   John-->Alice: Great!
   John->Bob: How about you?
   Bob-->John: Jolly good!

}}


and get this error:

[3f6e033d4535e9168d66d42b] /index.php?title=...&action=submit Error from line 35 of ...\mediawiki\extensions\Mermaid\src\ServiceWiring.php: Class 'Mermaid\Config' not found


Thanks in advance! :)

Javi

TheTomFinke (talkcontribs)

Probably the wrong and naive approach, but i dont have much experience in php and i got it to work

i just added

require_once('Config.php');

require_once('MermaidConfigExtractor.php');

to Mermaid/src/ServiceWiring.php, underneath the use statements

Reply to "Getting "...\mediawiki\extensions\Mermaid\src\ServiceWiring.php: Class 'Mermaid\Config' not found""

Rendering in some mobile browsers

1
Polymath uk (talkcontribs)

I have just tested the rendering of diagrams in various browsers and using all of the three default mediawiki themes. All seem to work fine on desktop browsers, (Sea Monkey, Dissenter, Brave, Opera, Chrome, etc).

I have had less success with mobile browsers. Chrome and clones (eg Kiwi, etc), Firefox are fine, but there is an issue with Brave. It renders some (eg graph boxes) as large with small text - ie the boxes are not sized to fit the text. I have tried applying em font sizes but this does not make a difference

{{#mermaid:graph TB

classDef default fill:#f9f,stroke:#333,stroke-width:4px,font-size:1.0em;

sq[Square shape] --> ci((Circle shape))

classDef green fill:#9f6,stroke:#333,stroke-width:2px,font-size:1.0em;

class sq,e green

}}

Reply to "Rendering in some mobile browsers"
130.76.24.15 (talkcontribs)

I've tried the example for the Mermaid documentation, with the mediawiki call, but it does not seem to work. I am using v3. All other types seem to work. Anyone else having issues?


{{#mermaid:journey

title My working day

section Go to work Make tea: 5: Me

Go upstairs: 3: Me

Do work: 1: Me, Cat

section Go home

Go downstairs: 5: Me

Sit down: 5: Me

}}

Polymath uk (talkcontribs)

There is an error in your syntax somewhere because this doesn't work on my site either. This does though:

{{#mermaid:graph TB

classDef default fill:#f9f,stroke:#333,stroke-width:4px,font-size:1.0em;

sq[Square shape] --> ci((Circle shape))

classDef green fill:#9f6,stroke:#333,stroke-width:2px,font-size:1.0em;

class sq,e green

}}

Reply to "User Journey Example?"

Use CSS to set "minimum width" of gantt tasks in pixels?

2
Revansx (talkcontribs)

Issue - Short tasks (duration << X axis range) do not render visibly when displayed on gantt charts with long (timespan >> task width).

Possible solution #1 - modify mermaid.js to "catch" tasks with "width=0" and add "1" to the width

Possible solution #2 - Use CSS to set "minimum-width" of tasks.


What to do?


Note: MW 1.34 w/ Mermaid v2.2.0

Revansx (talkcontribs)

I've played with the task elements in the browser's developer's tools and it would be ideal if Mermaid detected tasks with 'width="0"' and bumped them to 'width="1"'. Is that a mermaid.js feature or is that something that can be done in the Mediawiki Extension:Mermaid ?

Reply to "Use CSS to set "minimum width" of gantt tasks in pixels?"

Globally change flowchart theme in Common.css?

1
Yevvieart (talkcontribs)

Instead of defining class and linkstyle per chart, I'd prefer to change the way all charts display as default on my wiki. Could anyone point me to what css class and variables i'd have to use to enforce it?

Reply to "Globally change flowchart theme in Common.css?"