From 2d5e49fa151981baf1b69f2be27b87ac88f468b6 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Tue, 14 Jun 2022 17:49:05 +0200 Subject: [PATCH 01/14] --- src/mermaidAPI.js | 74 +---------------------------------------------- 1 file changed, 1 insertion(+), 73 deletions(-) diff --git a/src/mermaidAPI.js b/src/mermaidAPI.js index d985c3944..64a2f6331 100644 --- a/src/mermaidAPI.js +++ b/src/mermaidAPI.js @@ -74,11 +74,6 @@ function parse(text) { try { text = text + '\n'; const cnf = configApi.getConfig(); - const graphInit = utils.detectInit(text, cnf); - if (graphInit) { - reinitialize(graphInit); - log.info('reinit ', graphInit); - } const graphType = utils.detectType(text, cnf); let parser; @@ -90,10 +85,6 @@ function parse(text) { parser.parser.yy = gitGraphAst; break; case 'flowchart': - flowDb.clear(); - parser = flowParser; - parser.parser.yy = flowDb; - break; case 'flowchart-v2': flowDb.clear(); parser = flowParser; @@ -109,17 +100,11 @@ function parse(text) { parser.parser.yy = ganttDb; break; case 'class': - parser = classParser; - parser.parser.yy = classDb; - break; case 'classDiagram': parser = classParser; parser.parser.yy = classDb; break; case 'state': - parser = stateParser; - parser.parser.yy = stateDb; - break; case 'stateDiagram': parser = stateParser; parser.parser.yy = stateDb; @@ -261,7 +246,6 @@ const render = function (id, _txt, cb, container) { txt = 'graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa'; } - // let d3Iframe; let root = select('body'); // In regular execurtion the container will be the div with a mermaid class @@ -274,7 +258,6 @@ const render = function (id, _txt, cb, container) { .attr('id', 'i' + id) .attr('style', 'width: 100%; height: 100%;') .attr('sandbox', ''); - // const iframeBody = ; root = select(iframe.nodes()[0].contentDocument.body); root.node().style.margin = 0; } @@ -326,15 +309,6 @@ const render = function (id, _txt, cb, container) { element.remove(); } - // if (cnf.securityLevel === 'sandbox') { - // const iframe = select('body') - // .append('iframe') - // .attr('id', 'i' + id) - // .attr('sandbox', ''); - // // const iframeBody = ; - // root = select(iframe.nodes()[0].contentDocument.body); - // } - // Add the tmp div used for rendering with the id `d${id}` // d+id it will contain a svg with the id "id" @@ -346,7 +320,7 @@ const render = function (id, _txt, cb, container) { .attr('id', 'i' + id) .attr('style', 'width: 100%; height: 100%;') .attr('sandbox', ''); - // const iframeBody = ; + root = select(iframe.nodes()[0].contentDocument.body); root.node().style.margin = 0; } else { @@ -426,8 +400,6 @@ const render = function (id, _txt, cb, container) { } } - // log.warn(cnf.themeVariables); - const stylis = (selector, styles) => serialize(compile(`${selector}{${styles}}`), stringify); const rules = stylis(`#${id}`, getStyles(graphType, userStyles, cnf.themeVariables)); @@ -435,23 +407,9 @@ const render = function (id, _txt, cb, container) { style1.innerHTML = `#${id} ` + rules; svg.insertBefore(style1, firstChild); - // Verify that the generated svgs are ok before removing this - - // const style2 = document.createElement('style'); - // const cs = window.getComputedStyle(svg); - // style2.innerHTML = `#d${id} * { - // color: ${cs.color}; - // // font: ${cs.font}; - // // font-family: Arial; - // // font-size: 24px; - // }`; - // svg.insertBefore(style2, firstChild); - try { switch (graphType) { case 'gitGraph': - // cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; - //gitGraphRenderer.setConf(cnf.git); gitGraphRenderer.draw(txt, id, false); break; case 'flowchart': @@ -508,8 +466,6 @@ const render = function (id, _txt, cb, container) { infoRenderer.draw(txt, id, pkg.version); break; case 'pie': - //cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; - //pieRenderer.setConf(cnf.pie); pieRenderer.draw(txt, id, pkg.version); break; case 'er': @@ -526,7 +482,6 @@ const render = function (id, _txt, cb, container) { break; } } catch (e) { - // errorRenderer.setConf(cnf.class); errorRenderer.draw(id, pkg.version); throw e; } @@ -557,7 +512,6 @@ const render = function (id, _txt, cb, container) { let width = '100%'; let height = '100%'; if (svgEl) { - // width = svgEl.viewBox.baseVal.width + 'px'; height = svgEl.viewBox.baseVal.height + 'px'; } svgCode = `