Open shashank1010 opened 3 months ago
This is an issue we've identified a while back. But due to the internal implementation of how configs are handled, it's not possible for mermaid to apply a config for a single diagram.
We are making efforts to fix this, but as it'll require some major changes, it's been slow.
In the current situation, adding the mermaidOptions to the render function can't be handled by anything more than doing a mermaid.initialize
call inside the render function, as there is no diagram specific config available.
There's 275 calls to getConfig, which always returns the global config. All these would have to be modified, while passing down the config/db to each function that calls it.
One potential workaround is to add a function to get a site's config, enabling us to do something like this. But that's one hacky workraound.
const config = mermaid.getConfig();
mermaid.initialize(someOtherConfig);
await mermaid.render();
mermaid.initialize(config);
Proposal
Many thanks for creating, and maintaining this library.
I want to use themes with for my charts which Mermaid supports. However, correct me if I am wrong, here are my options.
mermaid.initialize
The problem:
Suggestion: It would be incredibly convenient if
mermaid.render
accepted an optional mermaid configuration which overwrites configuration specifically for this diagram. I have no use case for other options in mind other than updating theme, but this will make it super flexible.Example
In this issue on for the package rehype-mermaid, @remcohaszing highlights his inability to update chart specific configuration. https://github.com/remcohaszing/rehype-mermaid/issues/13
My thoughts of the updated syntax:
mermaid.render(id, diagram)
mermaid.render(id, diagram, element)
Screenshots
No response