Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get parse result of rendered graph? #1810

Open
SamKacer opened this issue Dec 6, 2020 · 0 comments
Open

How to get parse result of rendered graph? #1810

SamKacer opened this issue Dec 6, 2020 · 0 comments
Labels
Type: Other Not an enhancement or a bug Type: Question

Comments

@SamKacer
Copy link

SamKacer commented Dec 6, 2020

Hello, for the application I am developing, I need to get the parse result for a graph description, render said graph description, and be able to relate the two together via dom ids.

To explain further, my application essentially provides extra keyboard interaction for mermaid graphs to make them accessible to screen reader users. for this it requires a logical model of the graph. Such a logical model can be conveniently gotten using the parse method like this:

const parseResult = mermaid.mermaidAPI.parse(textContent).parser.yy

This returns an object described in src/diagrams/flowchart/flowDb.js, which has methods like getVertices, getEdges, getSubGraphs, which give me the information needed to put together a logical model of the graph, including dom ids for nodes I could use to relate to the rendered svg.

However the problem arises that then when I actually render the svg using the mermaid.mermaidAPI.render function, the ids for the nodes don't correspond to the dom ids I got for the parseResult. And so I can't use the dom ids I got earlier to relate my logical model to the rendered svg :(

I am guessing what is happening here, that each time mermaid parses a graph, it tries to assign globally unique ids for the nodes, so they dont clash with other mermaid graphs on the same page. since I do one parse call to get my logical model, and a render call to create the svg, in the render instance, the graph is parsed a second time and so the nodes are assigned different ids.

Hopefully this explains well enough the problem I have run into. Is there any way I can get the parse result produced during the render() call, so I can have a logical model where the dom ids actually correspond to the rendered svg?

Help is greatly appreciated!

@SamKacer SamKacer added Contributor needed Type: Other Not an enhancement or a bug labels Dec 6, 2020
@github-actions github-actions bot added the Status: Triage Needs to be verified, categorized, etc label Dec 6, 2020
@jgreywolf jgreywolf added Type: Question and removed Contributor needed Status: Triage Needs to be verified, categorized, etc labels Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Other Not an enhancement or a bug Type: Question
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants