mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-07 01:26:42 +02:00
Merge github.com:mermaid-js/mermaid into eslint-fix
This commit is contained in:
@@ -26,8 +26,12 @@ const conf = {
|
||||
/**
|
||||
* Function that adds the vertices found during parsing to the graph to be rendered.
|
||||
*
|
||||
* @param classes
|
||||
* @param g The graph that is to be drawn.
|
||||
* @param {Object<
|
||||
* string,
|
||||
* { cssClasses: string[]; text: string; id: string; type: string; domId: string }
|
||||
* >} classes
|
||||
* Object containing the vertices.
|
||||
* @param {SVGGElement} g The graph that is to be drawn.
|
||||
*/
|
||||
export const addClasses = function (classes, g) {
|
||||
// const svg = select(`[id="${svgId}"]`);
|
||||
@@ -210,7 +214,8 @@ export const addRelations = function (relations, g) {
|
||||
edgeData.arrowheadStyle = 'fill: #333';
|
||||
edgeData.labelpos = 'c';
|
||||
|
||||
if (getConfig().flowchart.htmlLabels) { // eslint-disable-line
|
||||
if (getConfig().flowchart.htmlLabels) {
|
||||
// eslint-disable-line
|
||||
edgeData.labelType = 'html';
|
||||
edgeData.label = '<span class="edgeLabel">' + edge.text + '</span>';
|
||||
} else {
|
||||
@@ -229,19 +234,25 @@ export const addRelations = function (relations, g) {
|
||||
});
|
||||
};
|
||||
|
||||
// Todo optimize
|
||||
/**
|
||||
* Gets the ID with the same label as in the cache
|
||||
*
|
||||
* @param {string} label The label to look for
|
||||
* @returns {string} The resulting ID
|
||||
*/
|
||||
const getGraphId = function (label) {
|
||||
const keys = Object.keys(idCache);
|
||||
const foundEntry = Object.entries(idCache).find((entry) => entry[1].label === label);
|
||||
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
if (idCache[keys[i]].label === label) {
|
||||
return keys[i];
|
||||
}
|
||||
if (foundEntry) {
|
||||
return foundEntry[0];
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Merges the value of `conf` with the passed `cnf`
|
||||
*
|
||||
* @param {object} cnf Config to merge
|
||||
*/
|
||||
export const setConf = function (cnf) {
|
||||
const keys = Object.keys(cnf);
|
||||
|
||||
@@ -253,8 +264,8 @@ export const setConf = function (cnf) {
|
||||
/**
|
||||
* Draws a flowchart in the tag with id: id based on the graph definition in text.
|
||||
*
|
||||
* @param text
|
||||
* @param id
|
||||
* @param {string} text
|
||||
* @param {string} id
|
||||
*/
|
||||
export const drawOld = function (text, id) {
|
||||
idCache = {};
|
||||
@@ -502,11 +513,12 @@ export const draw = function (text, id) {
|
||||
// });
|
||||
};
|
||||
|
||||
export default {
|
||||
setConf,
|
||||
draw,
|
||||
};
|
||||
/** @param type */
|
||||
/**
|
||||
* Gets the arrow marker for a type index
|
||||
*
|
||||
* @param {number} type The type to look for
|
||||
* @returns {'aggregation' | 'extension' | 'composition' | 'dependency'} The arrow marker
|
||||
*/
|
||||
function getArrowMarker(type) {
|
||||
let marker;
|
||||
switch (type) {
|
||||
@@ -527,3 +539,8 @@ function getArrowMarker(type) {
|
||||
}
|
||||
return marker;
|
||||
}
|
||||
|
||||
export default {
|
||||
setConf,
|
||||
draw,
|
||||
};
|
||||
|
Reference in New Issue
Block a user