mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-20 07:49:43 +02:00
Use courier in all rendering tests
This commit is contained in:
@@ -8,29 +8,43 @@ import config from './defaultConfig';
|
||||
export const defaultConfig = Object.freeze(config);
|
||||
|
||||
let siteConfig = assignWithDepth({}, defaultConfig);
|
||||
let siteConfigDelta;
|
||||
let directives = [];
|
||||
let currentConfig = assignWithDepth({}, defaultConfig);
|
||||
|
||||
export const updateCurrentConfig = (siteCfg, _directives) => {
|
||||
// start with config beeing the siteConfig
|
||||
let cfg = assignWithDepth({}, siteCfg);
|
||||
// let sCfg = assignWithDepth(defaultConfig, siteConfigDelta);
|
||||
|
||||
// Apply directives
|
||||
// Join directives
|
||||
let themeVariables = {};
|
||||
let sumOfDirectives = {};
|
||||
for (let i = 0; i < _directives.length; i++) {
|
||||
const d = _directives[i];
|
||||
sanitize(d);
|
||||
cfg = assignWithDepth(cfg, d);
|
||||
if (d.theme) {
|
||||
cfg.themeVariables = theme[cfg.theme].getThemeVariables(d.themeVariables);
|
||||
}
|
||||
|
||||
// Apply the data from the directive where the the overrides the themeVaraibles
|
||||
sumOfDirectives = assignWithDepth(sumOfDirectives, d);
|
||||
}
|
||||
if (cfg.theme && theme[cfg.theme]) {
|
||||
let tVars = assignWithDepth({}, cfg.themeVariables);
|
||||
tVars = assignWithDepth(tVars, themeVariables);
|
||||
const variables = theme[cfg.theme].getThemeVariables(tVars);
|
||||
cfg.themeVariables = variables;
|
||||
|
||||
cfg = assignWithDepth(cfg, sumOfDirectives);
|
||||
|
||||
if (sumOfDirectives.theme) {
|
||||
const themeVariables = assignWithDepth(
|
||||
siteConfigDelta.themeVariables || {},
|
||||
sumOfDirectives.themeVariables
|
||||
);
|
||||
cfg.themeVariables = theme[cfg.theme].getThemeVariables(themeVariables);
|
||||
}
|
||||
|
||||
// if (cfg.theme && theme[cfg.theme]) {
|
||||
// let tVars = assignWithDepth({}, cfg.themeVariables);
|
||||
// tVars = assignWithDepth(tVars, themeVariables);
|
||||
// const variables = theme[cfg.theme].getThemeVariables(tVars);
|
||||
// cfg.themeVariables = variables;
|
||||
// }
|
||||
|
||||
currentConfig = cfg;
|
||||
return cfg;
|
||||
};
|
||||
@@ -59,6 +73,28 @@ export const setSiteConfig = conf => {
|
||||
currentConfig = updateCurrentConfig(siteConfig, directives);
|
||||
return siteConfig;
|
||||
};
|
||||
const deepCopyFunction = inObject => {
|
||||
let outObject, value, key;
|
||||
|
||||
if (typeof inObject !== 'object' || inObject === null) {
|
||||
return inObject; // Return the value if inObject is not an object
|
||||
}
|
||||
|
||||
// Create an array or object to hold the values
|
||||
outObject = Array.isArray(inObject) ? [] : {};
|
||||
|
||||
for (key in inObject) {
|
||||
value = inObject[key];
|
||||
|
||||
// Recursively (deep) copy for nested objects, including arrays
|
||||
outObject[key] = deepCopyFunction(value);
|
||||
}
|
||||
|
||||
return outObject;
|
||||
};
|
||||
export const setSiteConfigDelta = conf => {
|
||||
siteConfigDelta = assignWithDepth({}, conf);
|
||||
};
|
||||
export const updateSiteConfig = conf => {
|
||||
siteConfig = assignWithDepth(siteConfig, conf);
|
||||
updateCurrentConfig(siteConfig, directives);
|
||||
|
Reference in New Issue
Block a user