mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
1473 Setting default config
This commit is contained in:
parent
2150933368
commit
5677523800
@ -341,5 +341,17 @@ context('Sequence diagram', () => {
|
||||
{ logLevel:0, sequence: { mirrorActors: false, noteFontSize: 18, noteFontFamily: 'Arial' } }
|
||||
);
|
||||
});
|
||||
it('should overide config with directive settings', () => {
|
||||
imgSnapshotTest(
|
||||
`
|
||||
sequenceDiagram
|
||||
%%{config: { "mirrorActors": false} }%%
|
||||
Alice->>Bob: I'm short
|
||||
note left of Alice: config set to mirrorActors: true<br/>directive set to mirrorActors: false
|
||||
Bob->>Alice: Short as well
|
||||
`,
|
||||
{ logLevel:0, sequence: { mirrorActors: true, noteFontSize: 18, noteFontFamily: 'Arial' } }
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
18
dist/mermaid.core.js
vendored
18
dist/mermaid.core.js
vendored
@ -832,7 +832,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
||||
var config = {};
|
||||
|
||||
var setConf = function setConf(cnf) {
|
||||
// Top level initially mermaid, gflow, sequenceDiagram and gantt
|
||||
console.log('config::setConf', cnf); // Top level initially mermaid, gflow, sequenceDiagram and gantt
|
||||
|
||||
var lvl1Keys = Object.keys(cnf);
|
||||
|
||||
for (var i = 0; i < lvl1Keys.length; i++) {
|
||||
@ -852,6 +853,8 @@ var setConf = function setConf(cnf) {
|
||||
config[lvl1Keys[i]] = cnf[lvl1Keys[i]];
|
||||
}
|
||||
}
|
||||
|
||||
console.log('config::setConf done', config);
|
||||
};
|
||||
|
||||
var setConfig = function setConfig(conf) {
|
||||
@ -20400,8 +20403,6 @@ var init = function init() {
|
||||
};
|
||||
|
||||
var initialize = function initialize(config) {
|
||||
console.log('Ininitializeze ', config);
|
||||
|
||||
if (typeof config.mermaid !== 'undefined') {
|
||||
if (typeof config.mermaid.startOnLoad !== 'undefined') {
|
||||
mermaid.startOnLoad = config.mermaid.startOnLoad;
|
||||
@ -21480,7 +21481,8 @@ var render = function render(id, _txt, cb, container) {
|
||||
};
|
||||
|
||||
var setConf = function setConf(cnf) {
|
||||
// Top level initially mermaid, gflow, sequenceDiagram and gantt
|
||||
console.log('set conf ', cnf); // Top level initially mermaid, gflow, sequenceDiagram and gantt
|
||||
|
||||
var lvl1Keys = Object.keys(cnf);
|
||||
|
||||
for (var i = 0; i < lvl1Keys.length; i++) {
|
||||
@ -21501,6 +21503,8 @@ var setConf = function setConf(cnf) {
|
||||
config[lvl1Keys[i]] = cnf[lvl1Keys[i]];
|
||||
}
|
||||
}
|
||||
|
||||
console.log('set conf done', config);
|
||||
};
|
||||
|
||||
function reinitialize(options) {
|
||||
@ -21518,10 +21522,14 @@ function reinitialize(options) {
|
||||
}
|
||||
|
||||
function initialize(options) {
|
||||
var _config = config; // Set default options
|
||||
console.log('initialize ', options, config, Object(_config__WEBPACK_IMPORTED_MODULE_3__["getConfig"])());
|
||||
|
||||
var _config = Object(_config__WEBPACK_IMPORTED_MODULE_3__["getConfig"])(); // Set default options
|
||||
|
||||
|
||||
if (_typeof(options) === 'object') {
|
||||
setConf(_config);
|
||||
Object(_config__WEBPACK_IMPORTED_MODULE_3__["setConfig"])(_config);
|
||||
}
|
||||
|
||||
_logger__WEBPACK_IMPORTED_MODULE_4__["logger"].debug('Initializing mermaidAPI ', {
|
||||
|
2
dist/mermaid.core.js.map
vendored
2
dist/mermaid.core.js.map
vendored
File diff suppressed because one or more lines are too long
18
dist/mermaid.js
vendored
18
dist/mermaid.js
vendored
@ -46615,7 +46615,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
||||
var config = {};
|
||||
|
||||
var setConf = function setConf(cnf) {
|
||||
// Top level initially mermaid, gflow, sequenceDiagram and gantt
|
||||
console.log('config::setConf', cnf); // Top level initially mermaid, gflow, sequenceDiagram and gantt
|
||||
|
||||
var lvl1Keys = Object.keys(cnf);
|
||||
|
||||
for (var i = 0; i < lvl1Keys.length; i++) {
|
||||
@ -46635,6 +46636,8 @@ var setConf = function setConf(cnf) {
|
||||
config[lvl1Keys[i]] = cnf[lvl1Keys[i]];
|
||||
}
|
||||
}
|
||||
|
||||
console.log('config::setConf done', config);
|
||||
};
|
||||
|
||||
var setConfig = function setConfig(conf) {
|
||||
@ -66159,8 +66162,6 @@ var init = function init() {
|
||||
};
|
||||
|
||||
var initialize = function initialize(config) {
|
||||
console.log('Ininitializeze ', config);
|
||||
|
||||
if (typeof config.mermaid !== 'undefined') {
|
||||
if (typeof config.mermaid.startOnLoad !== 'undefined') {
|
||||
mermaid.startOnLoad = config.mermaid.startOnLoad;
|
||||
@ -67238,7 +67239,8 @@ var render = function render(id, _txt, cb, container) {
|
||||
};
|
||||
|
||||
var setConf = function setConf(cnf) {
|
||||
// Top level initially mermaid, gflow, sequenceDiagram and gantt
|
||||
console.log('set conf ', cnf); // Top level initially mermaid, gflow, sequenceDiagram and gantt
|
||||
|
||||
var lvl1Keys = Object.keys(cnf);
|
||||
|
||||
for (var i = 0; i < lvl1Keys.length; i++) {
|
||||
@ -67259,6 +67261,8 @@ var setConf = function setConf(cnf) {
|
||||
config[lvl1Keys[i]] = cnf[lvl1Keys[i]];
|
||||
}
|
||||
}
|
||||
|
||||
console.log('set conf done', config);
|
||||
};
|
||||
|
||||
function reinitialize(options) {
|
||||
@ -67276,10 +67280,14 @@ function reinitialize(options) {
|
||||
}
|
||||
|
||||
function initialize(options) {
|
||||
var _config = config; // Set default options
|
||||
console.log('initialize ', options, config, Object(_config__WEBPACK_IMPORTED_MODULE_3__["getConfig"])());
|
||||
|
||||
var _config = Object(_config__WEBPACK_IMPORTED_MODULE_3__["getConfig"])(); // Set default options
|
||||
|
||||
|
||||
if (_typeof(options) === 'object') {
|
||||
setConf(_config);
|
||||
Object(_config__WEBPACK_IMPORTED_MODULE_3__["setConfig"])(_config);
|
||||
}
|
||||
|
||||
_logger__WEBPACK_IMPORTED_MODULE_4__["logger"].debug('Initializing mermaidAPI ', {
|
||||
|
2
dist/mermaid.js.map
vendored
2
dist/mermaid.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/mermaid.min.js
vendored
4
dist/mermaid.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/mermaid.min.js.map
vendored
2
dist/mermaid.min.js.map
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,7 @@
|
||||
let config = {};
|
||||
|
||||
const setConf = function(cnf) {
|
||||
// console.log('config::setConf', cnf);
|
||||
// Top level initially mermaid, gflow, sequenceDiagram and gantt
|
||||
const lvl1Keys = Object.keys(cnf);
|
||||
for (let i = 0; i < lvl1Keys.length; i++) {
|
||||
@ -19,6 +20,7 @@ const setConf = function(cnf) {
|
||||
config[lvl1Keys[i]] = cnf[lvl1Keys[i]];
|
||||
}
|
||||
}
|
||||
// console.log('config::setConf done', config);
|
||||
};
|
||||
|
||||
export const setConfig = conf => {
|
||||
|
@ -926,6 +926,7 @@ const render = function(id, _txt, cb, container) {
|
||||
};
|
||||
|
||||
const setConf = function(cnf) {
|
||||
// console.log('set conf ', cnf);
|
||||
// Top level initially mermaid, gflow, sequenceDiagram and gantt
|
||||
const lvl1Keys = Object.keys(cnf);
|
||||
for (let i = 0; i < lvl1Keys.length; i++) {
|
||||
@ -951,6 +952,7 @@ const setConf = function(cnf) {
|
||||
config[lvl1Keys[i]] = cnf[lvl1Keys[i]];
|
||||
}
|
||||
}
|
||||
// console.log('set conf done', config);
|
||||
};
|
||||
|
||||
function reinitialize(options) {
|
||||
@ -963,10 +965,12 @@ function reinitialize(options) {
|
||||
}
|
||||
|
||||
function initialize(options) {
|
||||
let _config = config;
|
||||
// console.log('initialize ', options, config, getConfig());
|
||||
let _config = getConfig();
|
||||
// Set default options
|
||||
if (typeof options === 'object') {
|
||||
setConf(_config);
|
||||
setConfig(_config);
|
||||
}
|
||||
logger.debug('Initializing mermaidAPI ', { version: pkg.version, options, _config });
|
||||
// Update default config with options supplied at initialization
|
||||
|
Loading…
x
Reference in New Issue
Block a user