Closed ppdouble closed 2 years ago
Can you please create a reproducible example? Maybe on codesandbox?
Can you please create a reproducible example? Maybe on codesandbox?
The reproducible example:
https://codesandbox.io/s/twilight-sound-15yn9?file=/index.html
<html>
<head>
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
</head>
<body>
<div id="diagram">
s=>start: Sta
e=>end: E
s->e
</div>
<div id="diagram2">
</div>
<!-- "https://cdnjs.cloudflare.com/ajax/libs/raphael/2.3.0/raphael.min.js" -->
<!-- "https://flowchart.js.org/flowchart-latest.js" -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.3.0/raphael.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/flowchart/1.16.0/flowchart.min.js"></script>
<script>
var hc = $("#diagram").text();
var diagram = flowchart.parse(hc);
$("#diagram2").text(hc+" - copy from diagram text");
diagram.drawSVG('diagram');
</script>
</body>
</html>
In my real case, I put the diagram
code snippet in the markdown editor, Editor.md
, when I am writing blog.
<div id="diagram">
s=>start: Sta
e=>end: E
s->e
</div>
The flowchart.js needs to get content from div
with jquery #id selector. But it shows the text content again after generating svg
tag.
Sorry, I have no idea what you're trying to do... And your link is not a reproducible example... This is my example, and it works: https://codesandbox.io/s/nostalgic-shadow-ckg4j?file=/index.html
Well, thank you, now, I know what I missed. I need a <div>
or <textarea>
with display:none
, so that flowchart.js
can get text from the display:none
tag and output to another <div>
with no content.
<div id="flowchartcode" style="display:none">
s=>start: Sta
e=>end: E
s->e
</div>
<div id="diagram">
</div>
<script>
var fcc = $("#flowchartcode").text();
var diagramobj = flowchart.parse(fcc);
diagramobj.drawSVG('diagram');
</script>
code like this
javascript:
html:
The chart shows correctly. But the original code will show again after svg tag.
<svg>...</svg> s=>start: Sta e=>end: E s->e
. What happened? Thank you.