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

[Bug] Can not use render method with mindmap and timeline #4089

Closed
Mister-Hope opened this issue Feb 15, 2023 · 4 comments · Fixed by #4108
Closed

[Bug] Can not use render method with mindmap and timeline #4089

Mister-Hope opened this issue Feb 15, 2023 · 4 comments · Fixed by #4108
Labels
Graph: Mindmap Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@Mister-Hope
Copy link
Contributor

Mister-Hope commented Feb 15, 2023

Description

Error diagram will be shown if rendering mindmap and timeline diagrams with mermaid.render() as they seems to be async. (Also they are also not working as expected with renderAsync)

Also, since mermaid:

  • does not provide a api to detect whether a diagram has been registered
  • will throw if registing a diagram that already registered before

The 3rd and 4th errors are triggered.

image

Step to reproduce:

use mermaid.render to render any content with timeline or mindmap

Related code:

Here diagrams are added during render:

However they are async:

registerLazyLoadedDiagrams(flowchartElk, timelineDetector, mindmapDetector);

Breaking changes unlisted

mermaid 9.3 use @mermaid-js/mermaid-mindmap for mindmap, however it's removed in repo and seems to be deprecated, this is NOT listed in changelog!

@Mister-Hope Mister-Hope added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Feb 15, 2023
@Mister-Hope Mister-Hope mentioned this issue Feb 16, 2023
4 tasks
@knsv
Copy link
Collaborator

knsv commented Feb 16, 2023

Thanks for pointing this out. We will add that to the release notes.

Mind maps has been included in the package so that users don't have to anything to have it available. This did not work properly. We have added another diagram, timeline, that likely will suffer from the same problem. We hoped to avoid breaking changes but missed this.

We were/are planning an api update to make all rendering async, that will be v10. I guess this accelerates that plan.

@Mister-Hope
Copy link
Contributor Author

We were/are planning an api update to make all rendering async, that will be v10. I guess this accelerates that plan.

Then maybe jsdocs is wrong?

This is not marked as deprecated:

/**
* Function that renders an svg with a graph from a chart definition. Usage example below.
*
* ```javascript
* mermaidAPI.initialize({
* startOnLoad: true,
* });
* $(function () {
* const graphDefinition = 'graph TB\na-->b';
* const cb = function (svgGraph) {
* console.log(svgGraph);
* };
* mermaidAPI.render('id1', graphDefinition, cb);
* });
* ```
*
* @param id - The id for the SVG element (the element to be rendered)
* @param text - The text for the graph definition
* @param cb - Callback which is called after rendering is finished with the svg code as in param.
* @param svgContainingElement - HTML element where the svg will be inserted. (Is usually element with the .mermaid class)
* If no svgContainingElement is provided then the SVG element will be appended to the body.
* Selector to element in which a div with the graph temporarily will be
* inserted. If one is provided a hidden div will be inserted in the body of the page instead. The
* element will be removed when rendering is completed.
* @returns Returns the rendered element as a string containing the SVG definition.
*/
const render = function (

However this is:

/**
* @deprecated This is an internal function and should not be used. Will be removed in v10.
*/
const renderAsync = async function (

@sidharthv96
Copy link
Member

#4091 (comment)

@sidharthv96
Copy link
Member

Fixed in v10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Graph: Mindmap Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants