diff --git a/cypress/platform/current.html b/cypress/platform/current.html
index e0bfb63af..8f0e3331b 100644
--- a/cypress/platform/current.html
+++ b/cypress/platform/current.html
@@ -74,8 +74,9 @@ stateDiagram-v2
A --> D: asd123
+ %%{init: {'theme': 'base', 'themeVariables':{ 'primaryColor': '#ff0000'}}}%%
- %%{init: {'theme': 'base', 'themeVariables':{ 'primaryColor': '#ff0000'}}}%%
+ %%{init: {'theme': 'base'}}%%
graph TB
subgraph apa
@@ -92,7 +93,7 @@ graph TD
C
end
-
+
sequenceDiagram
Alice->Bob: Hello Bob, how are you?
Note over Alice,Bob: Looks
@@ -105,8 +106,8 @@ Note over Bob,Alice: Looks back
// console.error('Mermaid error: ', err);
};
mermaid.initialize({
- theme: 'base',
- // themeVariables:{primaryColor: '#ff0000'},
+ // theme: 'base',
+ // themeVariables:{primaryColor: '#0000ff'},
// arrowMarkerAbsolute: true,
// themeCSS: '.edgePath .path {stroke: red;} .arrowheadPath {fill: red;}',
logLevel: 0,
diff --git a/src/config.js b/src/config.js
index 09da1e914..764216af4 100644
--- a/src/config.js
+++ b/src/config.js
@@ -15,20 +15,27 @@ export const updateCurrentConfig = (siteCfg, _directives) => {
let cfg = assignWithDepth({}, siteCfg);
// Apply directives
- let themeVariables;
- _directives.forEach(d => {
+ let themeVariables = {};
+ for (let i = 0; i < _directives.length; i++) {
+ const d = _directives[i];
sanitize(d);
cfg = assignWithDepth(cfg, d);
if (d.themeVariables) {
themeVariables = d.themeVariables;
}
- });
- if (themeVariables && currentConfig.theme && theme[currentConfig.theme]) {
- const variables = theme[currentConfig.theme].getThemeVariables(themeVariables);
+ }
+ if (cfg.theme && theme[cfg.theme]) {
+ // console.warn('cfg beeing updated main bkg', themeVariables, cfg.theme);
+ const variables = theme[cfg.theme].getThemeVariables(themeVariables);
+ // console.warn('cfg beeing updated 2 main bkg', variables.mainBkg);
cfg.themeVariables = variables;
}
+ // else {
+ // console.warn('cfg not beeing updated main bkg', themeVariables, cfg.theme);
+ // }
currentConfig = cfg;
+ // console.warn('cfg updated main bkg', cfg.sequence);
return cfg;
};
/**
@@ -49,7 +56,6 @@ export const setSiteConfig = conf => {
// siteConfig = { ...defaultConfig, ...conf };
siteConfig = assignWithDepth({}, defaultConfig);
siteConfig = assignWithDepth(siteConfig, conf);
- // console.warn(siteConfig.sequence);
currentConfig = updateCurrentConfig(siteConfig, directives);
return siteConfig;
};
@@ -165,6 +171,7 @@ export const reset = () => {
// Replace current config with siteConfig
directives = [];
+ // console.warn(siteConfig.sequence);
updateCurrentConfig(siteConfig, directives);
};
diff --git a/src/diagrams/sequence/sequenceDiagram.spec.js b/src/diagrams/sequence/sequenceDiagram.spec.js
index 1cc2f5bfd..f8f11a4a5 100644
--- a/src/diagrams/sequence/sequenceDiagram.spec.js
+++ b/src/diagrams/sequence/sequenceDiagram.spec.js
@@ -942,8 +942,8 @@ describe('when rendering a sequenceDiagram APA', function() {
wrap: false,
mirrorActors: false
};
+ console.warn('Set site config');
configApi.setSiteConfig({ logLevel: 5, sequence: conf });
- // console.warn('Config = ', configApi.getConfig())
});
let conf;
beforeEach(function() {
diff --git a/src/mermaidAPI.js b/src/mermaidAPI.js
index 3fb702e50..385bbd6f1 100644
--- a/src/mermaidAPI.js
+++ b/src/mermaidAPI.js
@@ -216,9 +216,10 @@ const render = function(id, _txt, cb, container) {
const siteConfig = configApi.getSiteConfig();
configApi.addDirective(siteConfig);
}
+ // console.warn('Render fetching config');
const cnf = configApi.getConfig();
- console.log('Render', cnf);
+ // console.warn('Render with config after adding new directives', cnf.themeVariables.mainBkg);
// 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';
@@ -294,6 +295,9 @@ const render = function(id, _txt, cb, container) {
}
}
}
+
+ // logger.warn(cnf.themeVariables);
+
const stylis = new Stylis();
const rules = stylis(`#${id}`, getStyles(graphType, userStyles, cnf.themeVariables));
@@ -578,8 +582,8 @@ const mermaidAPI = Object.freeze({
reset: () => {
console.warn('reset');
configApi.reset();
- const siteConfig = configApi.getSiteConfig();
- updateRendererConfigs(siteConfig);
+ // const siteConfig = configApi.getSiteConfig();
+ // updateRendererConfigs(siteConfig);
},
globalReset: () => {
configApi.reset(configApi.defaultConfig);
diff --git a/src/themes/theme-base.js b/src/themes/theme-base.js
index bf7c6e9ca..ddcb80536 100644
--- a/src/themes/theme-base.js
+++ b/src/themes/theme-base.js
@@ -56,6 +56,7 @@ class Theme {
this.nodeBkg = this.primaryColor;
this.mainBkg = this.primaryColor;
+ // console.warn('main bkg ', this.mainBkg);
this.nodeBorder = this.primaryBorderColor;
this.clusterBkg = this.tertiaryColor;
this.clusterBorder = this.tertiaryBorderColor;