diff --git a/e2e/platform/click.html b/e2e/platform/click.html new file mode 100644 index 000000000..de44a23c8 --- /dev/null +++ b/e2e/platform/click.html @@ -0,0 +1,23 @@ + + + + + + Mermaid Quick Test Page + + + +
+ graph TB + FullFirstSquad-->StripedFirstSquad + click FullFirstSquad showFullFirstSquad "show details" +
+ + + + diff --git a/src/diagrams/flowchart/flowDb.js b/src/diagrams/flowchart/flowDb.js index 6fc833787..f3717458a 100644 --- a/src/diagrams/flowchart/flowDb.js +++ b/src/diagrams/flowchart/flowDb.js @@ -18,7 +18,7 @@ let funs = [] const sanitize = text => { let txt = text - if (config.securityLevel === 'strict') { + if (config.securityLevel !== 'loose') { txt = txt.replace(/
/g, '#br#') txt = txt.replace(//g, '#br#') txt = txt.replace(//g, '>') @@ -182,13 +182,13 @@ export const setClass = function (ids, className) { const setTooltip = function (ids, tooltip) { ids.split(',').forEach(function (id) { if (typeof tooltip !== 'undefined') { - tooltips[id] = tooltip + tooltips[id] = sanitize(tooltip) } }) } const setClickFun = function (id, functionName) { - if (config.securityLevel === 'strict') { + if (config.securityLevel !== 'loose') { return } if (typeof functionName === 'undefined') { @@ -215,7 +215,7 @@ const setClickFun = function (id, functionName) { export const setLink = function (ids, linkStr, tooltip) { ids.split(',').forEach(function (id) { if (typeof vertices[id] !== 'undefined') { - if (config.securityLevel === 'strict') { + if (config.securityLevel !== 'loose') { vertices[id].link = sanitizeUrl(linkStr) // .replace(/javascript:.*/g, '') } else { vertices[id].link = linkStr diff --git a/src/diagrams/flowchart/flowRenderer.js b/src/diagrams/flowchart/flowRenderer.js index 896b02cf5..0715e8dc8 100644 --- a/src/diagrams/flowchart/flowRenderer.js +++ b/src/diagrams/flowchart/flowRenderer.js @@ -228,6 +228,7 @@ export const addEdges = function (edges, g) { * @returns {object} classDef styles */ export const getClasses = function (text) { + logger.info('Extracting classes') flowDb.clear() const parser = flow.parser parser.yy = flowDb @@ -243,7 +244,7 @@ export const getClasses = function (text) { * @param id */ export const draw = function (text, id) { - logger.debug('Drawing flowchart') + logger.info('Drawing flowchart') flowDb.clear() const parser = flow.parser parser.yy = flowDb diff --git a/src/diagrams/gantt/ganttDb.js b/src/diagrams/gantt/ganttDb.js index c5eb07e3c..46ba09e04 100644 --- a/src/diagrams/gantt/ganttDb.js +++ b/src/diagrams/gantt/ganttDb.js @@ -430,7 +430,7 @@ const compileTasks = function () { */ export const setLink = function (ids, _linkStr) { let linkStr = _linkStr - if (config.securityLevel === 'strict') { + if (config.securityLevel !== 'loose') { linkStr = sanitizeUrl(_linkStr) } ids.split(',').forEach(function (id) { @@ -457,7 +457,7 @@ export const setClass = function (ids, className) { } const setClickFun = function (id, functionName, functionArgs) { - if (config.securityLevel === 'strict') { + if (config.securityLevel !== 'loose') { return } if (typeof functionName === 'undefined') { diff --git a/src/mermaidAPI.js b/src/mermaidAPI.js index 12d697d0f..e8b75071a 100644 --- a/src/mermaidAPI.js +++ b/src/mermaidAPI.js @@ -497,10 +497,17 @@ const render = function (id, txt, cb, container) { svgCode = decodeEntities(svgCode) if (typeof cb !== 'undefined') { - cb(svgCode, flowDb.bindFunctions) - cb(svgCode, ganttDb.bindFunctions) + switch(graphType) { + case 'flowchart': + cb(svgCode, flowDb.bindFunctions) + break; + case 'gantt': + cb(svgCode, ganttDb.bindFunctions) + break; + default: + } } else { - logger.warn('CB = undefined!') + logger.debug('CB = undefined!') } const node = d3.select('#d' + id).node()