Skip to content

Commit

Permalink
Merge pull request #3330 from mermaid-js/3306_Fix_Gitgraph_Parsing_Issue
Browse files Browse the repository at this point in the history
Fix for GitGraphs not working for Mermaid Live Editor
  • Loading branch information
knsv committed Aug 18, 2022
2 parents b65c67e + a9e798c commit 02fc68a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/mermaidAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,21 @@ import utils, { directiveSanitizer } from './utils';
import assignWithDepth from './assignWithDepth';
import DOMPurify from 'dompurify';
import mermaid from './mermaid';

let hasLoadedDiagrams = false;

/**
* @param text
* @param dia
* @returns {any}
*/
function parse(text, dia) {
if (!hasLoadedDiagrams) {
addDiagrams();
hasLoadedDiagrams = true;
}
var parseEncounteredException = false;

try {
const diag = dia ? dia : new Diagram(text);
diag.db.clear();
Expand Down Expand Up @@ -512,7 +520,10 @@ function initialize(options) {

updateRendererConfigs(config);
setLogLevel(config.logLevel);
addDiagrams();
if (!hasLoadedDiagrams) {
addDiagrams();
hasLoadedDiagrams = true;
}
}

const mermaidAPI = Object.freeze({
Expand Down

0 comments on commit 02fc68a

Please sign in to comment.