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

Add the ability to link to pages #81

Open ehsteve opened 2 years ago

ehsteve commented 2 years ago

Setup and configuration

Issue

This is not a bug but a feature request. It would be great if mermaid graphs could link back to mediawiki pages. For example, a Gantt chart section could link to a page to provide more details. Same for a graph element.

kghbln commented 2 years ago

For graphs this works already using Mermaid's click feature: See the example on sandbox Not sure if it works for Gantt charts etc.

ehsteve commented 2 years ago

@kghbln thanks for pointing that out. That does seem to work though not for all elements in a gantt chart and in a way that is not very mediawiki friendly. For example, you have to hard code the web address as opposed to using the standard bracket notation. Also, it seems like only time bars can be changed to clickable and not other elements such as section names or milestone text. Section names are what I am most interested in being able to link to a page since they represent specific subjects. I understand that some of these limitations may come directly from mermaid and would have to be fixed there though I don't know which are which.

kghbln commented 2 years ago

If I am not mistaken, others may correct me here, this extension just wraps Mermaid code and allows to add it to a wiki page. Thus most of the changes need to be done at Mermaid I presume.

ehsteve commented 2 years ago

That may be true perhaps the only thing that would be appropriate here is to enable bracket linking for internal links?

djinnet commented 2 years ago

@kghbln I want to point out that example on sandbox is broken. I got 404 error when I am clicking on the link. I think it got moved somewhere elsewhere or it got taken down?

I am interesting in this issue as well, since I have the same use case feature as @ehsteve do.

At first I thought it was possible with [[InternalLink]] in the text, then it breaks. Then I read upon securityLevel and I tried it out based on this setup:

{{#mermaid:graph BT; A[AAA] --> Test B[BBB] A[AAA] --> Test C[[[InternalLink]]] C --> Test D[DDD] C --> Test E[EEE]

config.theme = dark config.securityLevel = loose }}

But it is broken. Then I tried just without the internal link and it still is broken, until I found out that config.securityLevel is the one who caused the error. It works fine without internallink and without securityLevel. Do both of ya know how I can resolve this securityLevel issue?

EDIT: Nevermind! Found out that I missed an " | " between theme and securityLevel and that solved the issue, but I still can't get the internal links. But for now I can use the antiscript or loose value in the securityLevel and use the a href tag instead, but it feels dirty to be honest when it is primary used for external links and not internal links.