mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-17 11:14:12 +01:00
1473 Class diagrams
This commit is contained in:
@@ -556,6 +556,8 @@ const config = {
|
|||||||
fontSize: 12
|
fontSize: 12
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
config.class.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
|
||||||
|
config.git.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
|
||||||
|
|
||||||
setLogLevel(config.logLevel);
|
setLogLevel(config.logLevel);
|
||||||
setConfig(config);
|
setConfig(config);
|
||||||
@@ -699,10 +701,10 @@ export const decodeEntities = function(text) {
|
|||||||
* completed.
|
* completed.
|
||||||
*/
|
*/
|
||||||
const render = function(id, _txt, cb, container) {
|
const render = function(id, _txt, cb, container) {
|
||||||
const config = getConfig();
|
const cnf = getConfig();
|
||||||
// Check the maximum allowed text size
|
// Check the maximum allowed text size
|
||||||
let txt = _txt;
|
let txt = _txt;
|
||||||
if (_txt.length > config.maxTextSize) {
|
if (_txt.length > cnf.maxTextSize) {
|
||||||
txt = 'graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa';
|
txt = 'graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -712,7 +714,7 @@ const render = function(id, _txt, cb, container) {
|
|||||||
select(container)
|
select(container)
|
||||||
.append('div')
|
.append('div')
|
||||||
.attr('id', 'd' + id)
|
.attr('id', 'd' + id)
|
||||||
.attr('style', 'font-family: ' + config.fontFamily)
|
.attr('style', 'font-family: ' + cnf.fontFamily)
|
||||||
.append('svg')
|
.append('svg')
|
||||||
.attr('id', id)
|
.attr('id', id)
|
||||||
.attr('width', '100%')
|
.attr('width', '100%')
|
||||||
@@ -753,22 +755,22 @@ const render = function(id, _txt, cb, container) {
|
|||||||
const firstChild = svg.firstChild;
|
const firstChild = svg.firstChild;
|
||||||
|
|
||||||
// pre-defined theme
|
// pre-defined theme
|
||||||
let style = themes[config.theme];
|
let style = themes[cnf.theme];
|
||||||
if (style === undefined) {
|
if (style === undefined) {
|
||||||
style = '';
|
style = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// user provided theme CSS
|
// user provided theme CSS
|
||||||
if (config.themeCSS !== undefined) {
|
if (cnf.themeCSS !== undefined) {
|
||||||
style += `\n${config.themeCSS}`;
|
style += `\n${cnf.themeCSS}`;
|
||||||
}
|
}
|
||||||
// user provided theme CSS
|
// user provided theme CSS
|
||||||
if (config.fontFamily !== undefined) {
|
if (cnf.fontFamily !== undefined) {
|
||||||
style += `\n:root { --mermaid-font-family: ${config.fontFamily}}`;
|
style += `\n:root { --mermaid-font-family: ${cnf.fontFamily}}`;
|
||||||
}
|
}
|
||||||
// user provided theme CSS
|
// user provided theme CSS
|
||||||
if (config.altFontFamily !== undefined) {
|
if (cnf.altFontFamily !== undefined) {
|
||||||
style += `\n:root { --mermaid-alt-font-family: ${config.altFontFamily}}`;
|
style += `\n:root { --mermaid-alt-font-family: ${cnf.altFontFamily}}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// classDef
|
// classDef
|
||||||
@@ -801,7 +803,7 @@ const render = function(id, _txt, cb, container) {
|
|||||||
try {
|
try {
|
||||||
switch (graphType) {
|
switch (graphType) {
|
||||||
case 'git':
|
case 'git':
|
||||||
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
|
cnf.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
|
||||||
gitGraphRenderer.setConf(config.git);
|
gitGraphRenderer.setConf(config.git);
|
||||||
gitGraphRenderer.draw(txt, id, false);
|
gitGraphRenderer.draw(txt, id, false);
|
||||||
break;
|
break;
|
||||||
@@ -834,8 +836,9 @@ const render = function(id, _txt, cb, container) {
|
|||||||
ganttRenderer.draw(txt, id);
|
ganttRenderer.draw(txt, id);
|
||||||
break;
|
break;
|
||||||
case 'class':
|
case 'class':
|
||||||
config.class.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
|
console.log(cnf, config);
|
||||||
classRenderer.setConf(config.class);
|
cnf.class.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
|
||||||
|
classRenderer.setConf(cnf.class);
|
||||||
classRenderer.draw(txt, id);
|
classRenderer.draw(txt, id);
|
||||||
break;
|
break;
|
||||||
case 'state':
|
case 'state':
|
||||||
@@ -868,7 +871,7 @@ const render = function(id, _txt, cb, container) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
errorRenderer.setConf(config.class);
|
// errorRenderer.setConf(config.class);
|
||||||
errorRenderer.draw(id, pkg.version);
|
errorRenderer.draw(id, pkg.version);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user