Move detectInit higher in the render function. This prevents getConfig from potentially being called with the config changes from previous diagrams on the same page (or context)

This also allows mermaid the chance to reset the config to the siteConfig in between renderings
This commit is contained in:
chris moran
2020-07-20 04:45:10 -04:00
parent 0297dd2664
commit f5f26f334f

View File

@@ -197,16 +197,20 @@ export const decodeEntities = function(text) {
* completed. * completed.
*/ */
const render = function(id, _txt, cb, container) { const render = function(id, _txt, cb, container) {
const cnf = getConfig();
// Check the maximum allowed text size
let txt = _txt; let txt = _txt;
if (_txt.length > cnf.maxTextSize) {
txt = 'graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa';
}
const graphInit = utils.detectInit(txt); const graphInit = utils.detectInit(txt);
if (graphInit) { if (graphInit) {
reinitialize(graphInit); reinitialize(graphInit);
assignWithDepth(cnf, getConfig()); } else {
configApi.reset();
const siteConfig = getSiteConfig();
updateRendererConfigs(siteConfig);
}
const cnf = getConfig();
// Check the maximum allowed text size
if (_txt.length > cnf.maxTextSize) {
txt = 'graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa';
} }
if (typeof container !== 'undefined') { if (typeof container !== 'undefined') {