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

The 'Mermaid with Text Area' CodePen example doesn't allow user to rerender the graph with new values #6124

Open
AMBudnik opened this issue Dec 11, 2024 · 0 comments
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@AMBudnik
Copy link

Description

I got the CodePend demo from https://mermaid.js.org/ecosystem/tutorials.html titled Mermaid with Text Area.
It works well when we click the render button button but it does not update.

Steps to reproduce

  1. Go to https://codepen.io/Ryuno-Ki/pen/LNxwgR
  2. Click the render button (graph is build correctly)
  3. Change
sequenceDiagram
A->> B: Query
B->> C: Forward query
Note right of C: Thinking...
C->> B: Response
B->> A: Forward response

to

sequenceDiagram
A->> B: QueryX
B->> C: Forward query
Note right of C: Thinking...
C->> B: Response
B->> A: Forward response

Result: graph is not rendered

Screenshots

No response

Code Sample

No response

Setup

Suggested Solutions

No response

Additional Context

User Story

I just want to build an option to pass what's in the textarea to the container that build the Mermaid

<div>
       <textarea name="" id="input" cols="30" rows="10" class="canvas-container">
     sequenceDiagram
     A->> B: Query
     B->> C: Forward query
     Note right of C: Thinking...
     C->> B: Response
     B->> A: Forward response
       </textarea>
     </div>
     <div>
       <button type="button" id="render" class="render-btn">Render</button>
     </div>
     <div>
       <div id="output"></div>
     </div>

     <script>
           const input = document.getElementById("input");
           const output = document.getElementById("output");
           const renderBtn = document.querySelector(".render-btn");

           mermaidAPI.initialize({startOnLoad: false});

           render.onclick = function() {
               mermaidAPI.render('theGraph', input.value, function(svgCode) {
                   output.innerHTML = svgCode;
               });
           }
     </script>
@AMBudnik AMBudnik added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests

1 participant