mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-20 15:59:51 +02:00
Revert of PR #1482
This commit is contained in:
@@ -1,19 +1,36 @@
|
||||
import { assignWithDepth } from './utils';
|
||||
const config = {};
|
||||
let config = {};
|
||||
|
||||
const setConf = function(cnf) {
|
||||
// Top level initially mermaid, gflow, sequenceDiagram and gantt
|
||||
const lvl1Keys = Object.keys(cnf);
|
||||
for (let i = 0; i < lvl1Keys.length; i++) {
|
||||
if (typeof cnf[lvl1Keys[i]] === 'object' && cnf[lvl1Keys[i]] != null) {
|
||||
const lvl2Keys = Object.keys(cnf[lvl1Keys[i]]);
|
||||
|
||||
for (let j = 0; j < lvl2Keys.length; j++) {
|
||||
// logger.debug('Setting conf ', lvl1Keys[i], '-', lvl2Keys[j])
|
||||
if (typeof config[lvl1Keys[i]] === 'undefined') {
|
||||
config[lvl1Keys[i]] = {};
|
||||
}
|
||||
// logger.debug('Setting config: ' + lvl1Keys[i] + ' ' + lvl2Keys[j] + ' to ' + cnf[lvl1Keys[i]][lvl2Keys[j]])
|
||||
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]];
|
||||
}
|
||||
} else {
|
||||
config[lvl1Keys[i]] = cnf[lvl1Keys[i]];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const setConfig = conf => {
|
||||
assignWithDepth(config, conf);
|
||||
setConf(conf);
|
||||
};
|
||||
export const getConfig = () => config;
|
||||
|
||||
export const reset = conf => {
|
||||
Object.keys(config).forEach(key => delete config[key]);
|
||||
assignWithDepth(config, conf, { clobber: true });
|
||||
};
|
||||
|
||||
const configApi = {
|
||||
setConfig,
|
||||
getConfig,
|
||||
reset
|
||||
getConfig
|
||||
// get conf() {
|
||||
// return config;
|
||||
// }
|
||||
};
|
||||
export default configApi;
|
||||
|
Reference in New Issue
Block a user