mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
Merge branch 'mmorel-35-eslint-fix' into develop
This commit is contained in:
commit
bb299685cd
@ -6,15 +6,20 @@
|
||||
},
|
||||
"parser": "@babel/eslint-parser",
|
||||
"parserOptions": {
|
||||
"ecmaFeatures": {
|
||||
"experimentalObjectRestSpread": true,
|
||||
"jsx": true
|
||||
},
|
||||
"sourceType": "module"
|
||||
"ecmaFeatures": {
|
||||
"experimentalObjectRestSpread": true,
|
||||
"jsx": true
|
||||
},
|
||||
"sourceType": "module"
|
||||
},
|
||||
"extends": ["prettier", "eslint:recommended"],
|
||||
"plugins": ["prettier"],
|
||||
"extends": ["eslint:recommended", "plugin:jsdoc/recommended", "plugin:prettier/recommended"],
|
||||
"plugins": ["jsdoc", "prettier"],
|
||||
"rules": {
|
||||
"prettier/prettier": ["error"]
|
||||
"jsdoc/check-indentation": 0,
|
||||
"jsdoc/check-alignment": 0,
|
||||
"jsdoc/check-line-alignment": 0,
|
||||
"jsdoc/multiline-blocks": 0,
|
||||
"jsdoc/newline-after-description": 0,
|
||||
"jsdoc/tag-lines": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"endOfLine": "auto",
|
||||
"plugins": ["prettier-plugin-jsdoc"],
|
||||
"printWidth": 100,
|
||||
"singleQuote": true,
|
||||
"endOfLine": "auto"
|
||||
"singleQuote": true
|
||||
}
|
||||
|
2266
dist/mermaid.core.js
vendored
2266
dist/mermaid.core.js
vendored
File diff suppressed because it is too large
Load Diff
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
2266
dist/mermaid.js
vendored
2266
dist/mermaid.js
vendored
File diff suppressed because it is too large
Load Diff
2
dist/mermaid.js.map
vendored
2
dist/mermaid.js.map
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
511
docs/Setup.md
511
docs/Setup.md
File diff suppressed because it is too large
Load Diff
@ -28,6 +28,7 @@
|
||||
"build:watch": "yarn build:development --watch",
|
||||
"release": "yarn build",
|
||||
"lint": "eslint src",
|
||||
"lint:fix": "yarn lint --fix",
|
||||
"e2e:depr": "yarn lint && jest e2e --config e2e/jest.config.js",
|
||||
"cypress": "percy exec -- cypress run",
|
||||
"e2e": "start-server-and-test dev http://localhost:9000/ cypress",
|
||||
@ -82,6 +83,7 @@
|
||||
"documentation": "13.2.0",
|
||||
"eslint": "^8.0.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-jsdoc": "^37.0.3",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"husky": "^7.0.1",
|
||||
"identity-obj-proxy": "^3.0.0",
|
||||
@ -91,6 +93,7 @@
|
||||
"moment": "^2.23.0",
|
||||
"path-browserify": "^1.0.1",
|
||||
"prettier": "^2.3.2",
|
||||
"prettier-plugin-jsdoc": "^0.3.30",
|
||||
"start-server-and-test": "^1.12.6",
|
||||
"terser-webpack-plugin": "^5.2.4",
|
||||
"webpack": "^5.53.0",
|
||||
@ -110,4 +113,4 @@
|
||||
"pre-push": "yarn test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
120
src/config.js
120
src/config.js
@ -43,18 +43,19 @@ export const updateCurrentConfig = (siteCfg, _directives) => {
|
||||
};
|
||||
|
||||
/**
|
||||
*## setSiteConfig
|
||||
*| Function | Description | Type | Values |
|
||||
*| --------- | ------------------- | ------- | ------------------ |
|
||||
*| setSiteConfig|Sets the siteConfig to desired values | Put Request | Any Values, except ones in secure array|
|
||||
***Notes:**
|
||||
*Sets the siteConfig. The siteConfig is a protected configuration for repeat use. Calls to reset() will reset
|
||||
*the currentConfig to siteConfig. Calls to reset(configApi.defaultConfig) will reset siteConfig and currentConfig
|
||||
*to the defaultConfig
|
||||
*Note: currentConfig is set in this function
|
||||
**Default value: At default, will mirror Global Config**
|
||||
* @param conf - the base currentConfig to use as siteConfig
|
||||
* @returns {Object} - the siteConfig
|
||||
* ## setSiteConfig
|
||||
*
|
||||
* | Function | Description | Type | Values |
|
||||
* | ------------- | ------------------------------------- | ----------- | --------------------------------------- |
|
||||
* | setSiteConfig | Sets the siteConfig to desired values | Put Request | Any Values, except ones in secure array |
|
||||
*
|
||||
* **Notes:** Sets the siteConfig. The siteConfig is a protected configuration for repeat use. Calls
|
||||
* to reset() will reset the currentConfig to siteConfig. Calls to reset(configApi.defaultConfig)
|
||||
* will reset siteConfig and currentConfig to the defaultConfig Note: currentConfig is set in this
|
||||
* function *Default value: At default, will mirror Global Config**
|
||||
*
|
||||
* @param conf - The base currentConfig to use as siteConfig
|
||||
* @returns {object} - The siteConfig
|
||||
*/
|
||||
export const setSiteConfig = (conf) => {
|
||||
siteConfig = assignWithDepth({}, defaultConfig);
|
||||
@ -79,28 +80,32 @@ export const updateSiteConfig = (conf) => {
|
||||
return siteConfig;
|
||||
};
|
||||
/**
|
||||
*## getSiteConfig
|
||||
*| Function | Description | Type | Values |
|
||||
*| --------- | ------------------- | ------- | ------------------ |
|
||||
*| setSiteConfig|Returns the current siteConfig base configuration | Get Request | Returns Any Values in siteConfig|
|
||||
***Notes**:
|
||||
*Returns **any** values in siteConfig.
|
||||
* @returns {Object} - the siteConfig
|
||||
* ## getSiteConfig
|
||||
*
|
||||
* | Function | Description | Type | Values |
|
||||
* | ------------- | ------------------------------------------------- | ----------- | -------------------------------- |
|
||||
* | setSiteConfig | Returns the current siteConfig base configuration | Get Request | Returns Any Values in siteConfig |
|
||||
*
|
||||
* **Notes**: Returns **any** values in siteConfig.
|
||||
*
|
||||
* @returns {object} - The siteConfig
|
||||
*/
|
||||
export const getSiteConfig = () => {
|
||||
return assignWithDepth({}, siteConfig);
|
||||
};
|
||||
/**
|
||||
*## setConfig
|
||||
*| Function | Description | Type | Values |
|
||||
*| --------- | ------------------- | ------- | ------------------ |
|
||||
*| setSiteConfig|Sets the siteConfig to desired values | Put Request| Any Values, except ones in secure array|
|
||||
***Notes**:
|
||||
*Sets the currentConfig. The parameter conf is sanitized based on the siteConfig.secure keys. Any
|
||||
*values found in conf with key found in siteConfig.secure will be replaced with the corresponding
|
||||
*siteConfig value.
|
||||
* @param conf - the potential currentConfig
|
||||
* @returns {*} - the currentConfig merged with the sanitized conf
|
||||
* ## setConfig
|
||||
*
|
||||
* | Function | Description | Type | Values |
|
||||
* | ------------- | ------------------------------------- | ----------- | --------------------------------------- |
|
||||
* | setSiteConfig | Sets the siteConfig to desired values | Put Request | Any Values, except ones in secure array |
|
||||
*
|
||||
* **Notes**: Sets the currentConfig. The parameter conf is sanitized based on the siteConfig.secure
|
||||
* keys. Any values found in conf with key found in siteConfig.secure will be replaced with the
|
||||
* corresponding siteConfig value.
|
||||
*
|
||||
* @param {any} conf - The potential currentConfig
|
||||
* @returns {any} - The currentConfig merged with the sanitized conf
|
||||
*/
|
||||
export const setConfig = (conf) => {
|
||||
// sanitize(conf);
|
||||
@ -115,25 +120,30 @@ export const setConfig = (conf) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* ## getConfig
|
||||
*| Function | Description | Type | Return Values |
|
||||
*| --------- | ------------------- | ------- | ------------------ |
|
||||
*| getConfig |Obtains the currentConfig | Get Request | Any Values from currentConfig|
|
||||
***Notes**:
|
||||
*Returns **any** the currentConfig
|
||||
* @returns {*} - the currentConfig
|
||||
* ## getConfig
|
||||
*
|
||||
* | Function | Description | Type | Return Values |
|
||||
* | --------- | ------------------------- | ----------- | ------------------------------ |
|
||||
* | getConfig | Obtains the currentConfig | Get Request | Any Values from current Config |
|
||||
*
|
||||
* **Notes**: Returns **any** the currentConfig
|
||||
*
|
||||
* @returns {any} - The currentConfig
|
||||
*/
|
||||
export const getConfig = () => {
|
||||
return assignWithDepth({}, currentConfig);
|
||||
};
|
||||
/**
|
||||
*## sanitize
|
||||
*| Function | Description | Type | Values |
|
||||
*| --------- | ------------------- | ------- | ------------------ |
|
||||
*| sanitize |Sets the siteConfig to desired values. | Put Request |None|
|
||||
*Ensures options parameter does not attempt to override siteConfig secure keys
|
||||
*Note: modifies options in-place
|
||||
* @param options - the potential setConfig parameter
|
||||
* ## sanitize
|
||||
*
|
||||
* | Function | Description | Type | Values |
|
||||
* | -------- | -------------------------------------- | ----------- | ------ |
|
||||
* | sanitize | Sets the siteConfig to desired values. | Put Request | None |
|
||||
*
|
||||
* Ensures options parameter does not attempt to override siteConfig secure keys **Notes**: modifies
|
||||
* options in-place
|
||||
*
|
||||
* @param {any} options - The potential setConfig parameter
|
||||
*/
|
||||
export const sanitize = (options) => {
|
||||
// Checking that options are not in the list of excluded options
|
||||
@ -175,7 +185,8 @@ export const sanitize = (options) => {
|
||||
|
||||
/**
|
||||
* Pushes in a directive to the configuration
|
||||
* @param {Object} directive The directive to push in
|
||||
*
|
||||
* @param {object} directive The directive to push in
|
||||
*/
|
||||
export const addDirective = (directive) => {
|
||||
if (directive.fontFamily) {
|
||||
@ -192,18 +203,19 @@ export const addDirective = (directive) => {
|
||||
};
|
||||
|
||||
/**
|
||||
*## reset
|
||||
*| Function | Description | Type | Required | Values |
|
||||
*| --------- | ------------------- | ------- | -------- | ------------------ |
|
||||
*| reset|Resets currentConfig to conf| Put Request | Required | None|
|
||||
* ## reset
|
||||
*
|
||||
*| Parameter | Description |Type | Required | Values|
|
||||
*| --- | --- | --- | --- | --- |
|
||||
*| conf| base set of values, which currentConfig coul be **reset** to.| Dictionary | Required | Any Values, with respect to the secure Array|
|
||||
* | Function | Description | Type | Required | Values |
|
||||
* | -------- | ---------------------------- | ----------- | -------- | ------ |
|
||||
* | reset | Resets currentConfig to conf | Put Request | Required | None |
|
||||
*
|
||||
**Notes :
|
||||
(default: current siteConfig ) (optional, default `getSiteConfig()`)
|
||||
* @param conf the base currentConfig to reset to (default: current siteConfig ) (optional, default `getSiteConfig()`)
|
||||
* ## conf
|
||||
*
|
||||
* | Parameter | Description | Type | Required | Values |
|
||||
* | --------- | ------------------------------------------------------------- | ---------- | -------- | -------------------------------------------- |
|
||||
* | conf | base set of values, which currentConfig coul be **reset** to. | Dictionary | Required | Any Values, with respect to the secure Array |
|
||||
*
|
||||
* **Notes**: (default: current siteConfig ) (optional, default `getSiteConfig()`)
|
||||
*/
|
||||
export const reset = () => {
|
||||
// Replace current config with siteConfig
|
||||
|
@ -3,13 +3,6 @@ import { log } from './logger'; // eslint-disable-line
|
||||
import theme from './themes';
|
||||
import config from './defaultConfig';
|
||||
|
||||
// import { unflatten } from 'flat';
|
||||
// import flatten from 'flat';
|
||||
|
||||
// import themeVariables from './theme-default';
|
||||
// import themeForestVariables from './theme-forest';
|
||||
// import themeNeutralVariables from './theme-neutral';
|
||||
|
||||
const handleThemeVariables = (value) => {
|
||||
return theme[value] ? theme[value].getThemeVariables() : theme.default.getThemeVariables();
|
||||
};
|
||||
@ -27,18 +20,19 @@ const siteConfig = assignWithDepth({}, defaultConfig);
|
||||
const currentConfig = assignWithDepth({}, defaultConfig);
|
||||
|
||||
/**
|
||||
*## setSiteConfig
|
||||
*| Function | Description | Type | Values |
|
||||
*| --------- | ------------------- | ------- | ------------------ |
|
||||
*| setSiteConfig|Sets the siteConfig to desired values | Put Request | Any Values, except ones in secure array|
|
||||
***Notes:**
|
||||
*Sets the siteConfig. The siteConfig is a protected configuration for repeat use. Calls to reset() will reset
|
||||
*the currentConfig to siteConfig. Calls to reset(configApi.defaultConfig) will reset siteConfig and currentConfig
|
||||
*to the defaultConfig
|
||||
*Note: currentConfig is set in this function
|
||||
**Default value: At default, will mirror Global Config**
|
||||
* @param conf - the base currentConfig to use as siteConfig
|
||||
* @returns {*} - the siteConfig
|
||||
* ## setSiteConfig
|
||||
*
|
||||
* | Function | Description | Type | Values |
|
||||
* | ------------- | ------------------------------------- | ----------- | --------------------------------------- |
|
||||
* | setSiteConfig | Sets the siteConfig to desired values | Put Request | Any Values, except ones in secure array |
|
||||
*
|
||||
* **Notes:** Sets the siteConfig. The siteConfig is a protected configuration for repeat use. Calls
|
||||
* to reset() will reset the currentConfig to siteConfig. Calls to reset(configApi.defaultConfig)
|
||||
* will reset siteConfig and currentConfig to the defaultConfig Note: currentConfig is set in this
|
||||
* function Default value: At default, will mirror Global Config
|
||||
*
|
||||
* @param {any} conf - The base currentConfig to use as siteConfig
|
||||
* @returns {any} - The siteConfig
|
||||
*/
|
||||
export const setSiteConfig = (conf) => {
|
||||
console.log('setSiteConfig');
|
||||
@ -55,28 +49,32 @@ export const setSiteConfig = (conf) => {
|
||||
return getSiteConfig();
|
||||
};
|
||||
/**
|
||||
*## getSiteConfig
|
||||
*| Function | Description | Type | Values |
|
||||
*| --------- | ------------------- | ------- | ------------------ |
|
||||
*| setSiteConfig|Returns the current siteConfig base configuration | Get Request | Returns Any Values in siteConfig|
|
||||
***Notes**:
|
||||
*Returns **any** values in siteConfig.
|
||||
* @returns {*}
|
||||
* ## getSiteConfig
|
||||
*
|
||||
* | Function | Description | Type | Values |
|
||||
* | ------------- | ------------------------------------------------- | ----------- | -------------------------------- |
|
||||
* | setSiteConfig | Returns the current siteConfig base configuration | Get Request | Returns Any Values in siteConfig |
|
||||
*
|
||||
* **Notes**: Returns **any** values in siteConfig.
|
||||
*
|
||||
* @returns {any}
|
||||
*/
|
||||
export const getSiteConfig = () => {
|
||||
return assignWithDepth({}, siteConfig);
|
||||
};
|
||||
/**
|
||||
*## setConfig
|
||||
*| Function | Description | Type | Values |
|
||||
*| --------- | ------------------- | ------- | ------------------ |
|
||||
*| setSiteConfig|Sets the siteConfig to desired values | Put Request| Any Values, except ones in secure array|
|
||||
***Notes**:
|
||||
*Sets the currentConfig. The parameter conf is sanitized based on the siteConfig.secure keys. Any
|
||||
*values found in conf with key found in siteConfig.secure will be replaced with the corresponding
|
||||
*siteConfig value.
|
||||
* @param conf - the potential currentConfig
|
||||
* @returns {*} - the currentConfig merged with the sanitized conf
|
||||
* ## setConfig
|
||||
*
|
||||
* | Function | Description | Type | Values |
|
||||
* | ------------- | ------------------------------------- | ----------- | --------------------------------------- |
|
||||
* | setSiteConfig | Sets the siteConfig to desired values | Put Request | Any Values, except ones in secure array |
|
||||
*
|
||||
* **Notes**: Sets the currentConfig. The parameter conf is sanitized based on the siteConfig.secure
|
||||
* keys. Any values found in conf with key found in siteConfig.secure will be replaced with the
|
||||
* corresponding siteConfig value.
|
||||
*
|
||||
* @param {any} conf - The potential currentConfig
|
||||
* @returns {any} - The currentConfig merged with the sanitized conf
|
||||
*/
|
||||
export const setConfig = (conf) => {
|
||||
console.log('setConfig');
|
||||
@ -90,25 +88,30 @@ export const setConfig = (conf) => {
|
||||
return getConfig();
|
||||
};
|
||||
/**
|
||||
* ## getConfig
|
||||
*| Function | Description | Type | Return Values |
|
||||
*| --------- | ------------------- | ------- | ------------------ |
|
||||
*| getConfig |Obtains the currentConfig | Get Request | Any Values from currentConfig|
|
||||
***Notes**:
|
||||
*Returns **any** the currentConfig
|
||||
* @returns {*} - the currentConfig
|
||||
* ## getConfig
|
||||
*
|
||||
* | Function | Description | Type | Return Values |
|
||||
* | --------- | ------------------------- | ----------- | ----------------------------- |
|
||||
* | getConfig | Obtains the currentConfig | Get Request | Any Values from currentConfig |
|
||||
*
|
||||
* **Notes**: Returns **any** the currentConfig
|
||||
*
|
||||
* @returns {any} - The currentConfig
|
||||
*/
|
||||
export const getConfig = () => {
|
||||
return assignWithDepth({}, currentConfig);
|
||||
};
|
||||
/**
|
||||
*## sanitize
|
||||
*| Function | Description | Type | Values |
|
||||
*| --------- | ------------------- | ------- | ------------------ |
|
||||
*| sanitize |Sets the siteConfig to desired values. | Put Request |None|
|
||||
*Ensures options parameter does not attempt to override siteConfig secure keys
|
||||
*Note: modifies options in-place
|
||||
* @param options - the potential setConfig parameter
|
||||
* ## sanitize
|
||||
*
|
||||
* | Function | Description | Type | Values |
|
||||
* | -------- | -------------------------------------- | ----------- | ------ |
|
||||
* | sanitize | Sets the siteConfig to desired values. | Put Request | None |
|
||||
*
|
||||
* Ensures options parameter does not attempt to override siteConfig secure keys **Notes**: modifies
|
||||
* options in-place
|
||||
*
|
||||
* @param {any} options - The potential setConfig parameter
|
||||
*/
|
||||
export const sanitize = (options) => {
|
||||
Object.keys(siteConfig.secure).forEach((key) => {
|
||||
@ -124,18 +127,20 @@ export const sanitize = (options) => {
|
||||
});
|
||||
};
|
||||
/**
|
||||
*## reset
|
||||
*| Function | Description | Type | Required | Values |
|
||||
*| --------- | ------------------- | ------- | -------- | ------------------ |
|
||||
*| reset|Resets currentConfig to conf| Put Request | Required | None|
|
||||
* ## reset
|
||||
*
|
||||
*| Parameter | Description |Type | Required | Values|
|
||||
*| --- | --- | --- | --- | --- |
|
||||
*| conf| base set of values, which currentConfig coul be **reset** to.| Dictionary | Required | Any Values, with respect to the secure Array|
|
||||
* | Function | Description | Type | Required | Values |
|
||||
* | -------- | ---------------------------- | ----------- | -------- | ------ |
|
||||
* | reset | Resets currentConfig to conf | Put Request | Required | None |
|
||||
*
|
||||
**Notes :
|
||||
(default: current siteConfig ) (optional, default `getSiteConfig()`)
|
||||
* @param conf - the base currentConfig to reset to (default: current siteConfig )
|
||||
* | Parameter | Description |Type | Required | Values|
|
||||
*
|
||||
* | --- | --- | --- | --- | --- |
|
||||
* | conf| base set of values, which currentConfig coul be **reset** to.| Dictionary | Required | Any Values, with respect to the secure Array|
|
||||
*
|
||||
* **Notes**: (default: current siteConfig ) (optional, default `getSiteConfig()`)
|
||||
*
|
||||
* @param {any} conf - The base currentConfig to reset to (default: current siteConfig )
|
||||
*/
|
||||
export const reset = (conf = getSiteConfig()) => {
|
||||
console.warn('reset');
|
||||
|
@ -79,6 +79,10 @@ const rect = (parent, node) => {
|
||||
|
||||
/**
|
||||
* Non visiable cluster where the note is group with its
|
||||
*
|
||||
* @param {any} parent
|
||||
* @param {any} node
|
||||
* @returns {any} ShapeSvg
|
||||
*/
|
||||
const noteGroup = (parent, node) => {
|
||||
// Add outer g element
|
||||
|
@ -2,65 +2,22 @@ import { select } from 'd3';
|
||||
import { log } from '../logger'; // eslint-disable-line
|
||||
import { getConfig } from '../config';
|
||||
import { evaluate } from '../diagrams/common/common';
|
||||
// let vertexNode;
|
||||
// if (evaluate(getConfig().flowchart.htmlLabels)) {
|
||||
// // TODO: addHtmlLabel accepts a labelStyle. Do we possibly have that?
|
||||
// const node = {
|
||||
// label: vertexText.replace(/fa[lrsb]?:fa-[\w-]+/g, s => `<i class='${s.replace(':', ' ')}'></i>`)
|
||||
// };
|
||||
// vertexNode = addHtmlLabel(svg, node).node();
|
||||
// vertexNode.parentNode.removeChild(vertexNode);
|
||||
// } else {
|
||||
// const svgLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
||||
// svgLabel.setAttribute('style', styles.labelStyle.replace('color:', 'fill:'));
|
||||
|
||||
// const rows = vertexText.split(common.lineBreakRegex);
|
||||
|
||||
// for (let j = 0; j < rows.length; j++) {
|
||||
// const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');
|
||||
// tspan.setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:space', 'preserve');
|
||||
// tspan.setAttribute('dy', '1em');
|
||||
// tspan.setAttribute('x', '1');
|
||||
// tspan.textContent = rows[j];
|
||||
// svgLabel.appendChild(tspan);
|
||||
// }
|
||||
// vertexNode = svgLabel;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @param dom
|
||||
* @param styleFn
|
||||
*/
|
||||
function applyStyle(dom, styleFn) {
|
||||
if (styleFn) {
|
||||
dom.attr('style', styleFn);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} node
|
||||
* @returns {SVGForeignObjectElement} Node
|
||||
*/
|
||||
function addHtmlLabel(node) {
|
||||
// var fo = root.append('foreignObject').attr('width', '100000');
|
||||
|
||||
// var div = fo.append('xhtml:div');
|
||||
// div.attr('xmlns', 'http://www.w3.org/1999/xhtml');
|
||||
|
||||
// var label = node.label;
|
||||
// switch (typeof label) {
|
||||
// case 'function':
|
||||
// div.insert(label);
|
||||
// break;
|
||||
// case 'object':
|
||||
// // Currently we assume this is a DOM object.
|
||||
// div.insert(function() {
|
||||
// return label;
|
||||
// });
|
||||
// break;
|
||||
// default:
|
||||
// div.html(label);
|
||||
// }
|
||||
|
||||
// applyStyle(div, node.labelStyle);
|
||||
// div.style('display', 'inline-block');
|
||||
// // Fix for firefox
|
||||
// div.style('white-space', 'nowrap');
|
||||
|
||||
// var client = div.node().getBoundingClientRect();
|
||||
// fo.attr('width', client.width).attr('height', client.height);
|
||||
const fo = select(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'));
|
||||
const div = fo.append('xhtml:div');
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { log } from '../logger'; // eslint-disable-line
|
||||
import createLabel from './createLabel';
|
||||
// import { line, curveBasis, curveLinear, select } from 'd3';
|
||||
import { line, curveBasis, select } from 'd3';
|
||||
import { getConfig } from '../config';
|
||||
import utils from '../utils';
|
||||
@ -110,6 +109,10 @@ export const insertEdgeLabel = (elem, edge) => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} fo
|
||||
* @param {any} value
|
||||
*/
|
||||
function setTerminalWidth(fo, value) {
|
||||
if (getConfig().flowchart.htmlLabels && fo) {
|
||||
fo.style.width = value.length * 9 + 'px';
|
||||
@ -306,9 +309,10 @@ export const intersection = (node, outsidePoint, insidePoint) => {
|
||||
/**
|
||||
* This function will page a path and node where the last point(s) in the path is inside the node
|
||||
* and return an update path ending by the border of the node.
|
||||
* @param {*} points
|
||||
* @param {*} boundryNode
|
||||
* @returns
|
||||
*
|
||||
* @param {Array} _points
|
||||
* @param {any} boundryNode
|
||||
* @returns {Array} Points
|
||||
*/
|
||||
const cutPathAtIntersect = (_points, boundryNode) => {
|
||||
log.warn('abc88 cutPathAtIntersect', _points, boundryNode);
|
||||
|
@ -1,5 +1,10 @@
|
||||
import intersectEllipse from './intersect-ellipse';
|
||||
|
||||
/**
|
||||
* @param node
|
||||
* @param rx
|
||||
* @param point
|
||||
*/
|
||||
function intersectCircle(node, rx, point) {
|
||||
return intersectEllipse(node, rx, rx, point);
|
||||
}
|
||||
|
@ -1,3 +1,9 @@
|
||||
/**
|
||||
* @param node
|
||||
* @param rx
|
||||
* @param ry
|
||||
* @param point
|
||||
*/
|
||||
function intersectEllipse(node, rx, ry, point) {
|
||||
// Formulae from: http://mathworld.wolfram.com/Ellipse-LineIntersection.html
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
/*
|
||||
* Returns the point at which two lines, p and q, intersect or returns
|
||||
* undefined if they do not intersect.
|
||||
/**
|
||||
* Returns the point at which two lines, p and q, intersect or returns undefined if they do not intersect.
|
||||
*
|
||||
* @param p1
|
||||
* @param p2
|
||||
* @param q1
|
||||
* @param q2
|
||||
*/
|
||||
function intersectLine(p1, p2, q1, q2) {
|
||||
// Algorithm from J. Avro, (ed.) Graphics Gems, No 2, Morgan Kaufmann, 1994,
|
||||
@ -63,6 +67,10 @@ function intersectLine(p1, p2, q1, q2) {
|
||||
return { x: x, y: y };
|
||||
}
|
||||
|
||||
/**
|
||||
* @param r1
|
||||
* @param r2
|
||||
*/
|
||||
function sameSign(r1, r2) {
|
||||
return r1 * r2 > 0;
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
module.exports = intersectNode;
|
||||
|
||||
/**
|
||||
* @param node
|
||||
* @param point
|
||||
*/
|
||||
function intersectNode(node, point) {
|
||||
// console.info('Intersect Node');
|
||||
return node.intersect(point);
|
||||
|
@ -4,9 +4,13 @@ import intersectLine from './intersect-line';
|
||||
|
||||
export default intersectPolygon;
|
||||
|
||||
/*
|
||||
* Returns the point ({x, y}) at which the point argument intersects with the
|
||||
* node argument assuming that it has the shape specified by polygon.
|
||||
/**
|
||||
* Returns the point ({x, y}) at which the point argument intersects with the node argument assuming
|
||||
* that it has the shape specified by polygon.
|
||||
*
|
||||
* @param node
|
||||
* @param polyPoints
|
||||
* @param point
|
||||
*/
|
||||
function intersectPolygon(node, polyPoints, point) {
|
||||
var x1 = node.x;
|
||||
|
@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Setup arrow head and define the marker. The result is appended to the svg.
|
||||
*/
|
||||
/** Setup arrow head and define the marker. The result is appended to the svg. */
|
||||
|
||||
import { log } from '../logger';
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Decorates with functions required by mermaids dagre-wrapper.
|
||||
*/
|
||||
/** Decorates with functions required by mermaids dagre-wrapper. */
|
||||
import { log } from '../logger';
|
||||
import graphlib from 'graphlib';
|
||||
|
||||
@ -145,7 +143,8 @@ export const extractDecendants = (id, graph) => {
|
||||
/**
|
||||
* Validates the graph, checking that all parent child relation points to existing nodes and that
|
||||
* edges between nodes also ia correct. When not correct the function logs the discrepancies.
|
||||
* @param {graphlib graph} g
|
||||
*
|
||||
* @param graph
|
||||
*/
|
||||
export const validate = (graph) => {
|
||||
const edges = graph.edges();
|
||||
@ -165,8 +164,9 @@ export const validate = (graph) => {
|
||||
|
||||
/**
|
||||
* Finds a child that is not a cluster. When faking a edge between a node and a cluster.
|
||||
* @param {Finds a } id
|
||||
* @param {*} graph
|
||||
*
|
||||
* @param {Finds a} id
|
||||
* @param {any} graph
|
||||
*/
|
||||
export const findNonClusterChild = (id, graph) => {
|
||||
// const node = graph.node(id);
|
||||
|
@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Setup arrow head and define the marker. The result is appended to the svg.
|
||||
*/
|
||||
/** Setup arrow head and define the marker. The result is appended to the svg. */
|
||||
|
||||
// import { log } from '../logger';
|
||||
|
||||
|
@ -55,6 +55,12 @@ export const updateNodeBounds = (node, element) => {
|
||||
node.height = bbox.height;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param w
|
||||
* @param h
|
||||
* @param points
|
||||
*/
|
||||
export function insertPolygonShape(parent, w, h, points) {
|
||||
return parent
|
||||
.insert('polygon', ':first-child')
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -33,6 +33,7 @@ const splitClassNameAndType = function (id) {
|
||||
|
||||
/**
|
||||
* Function called by parser when a node definition has been found.
|
||||
*
|
||||
* @param id
|
||||
* @public
|
||||
*/
|
||||
@ -56,6 +57,7 @@ export const addClass = function (id) {
|
||||
|
||||
/**
|
||||
* Function to lookup domId from id in the graph definition.
|
||||
*
|
||||
* @param id
|
||||
* @public
|
||||
*/
|
||||
@ -98,8 +100,9 @@ export const addRelation = function (relation) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds an annotation to the specified class
|
||||
* Annotations mark special properties of the given type (like 'interface' or 'service')
|
||||
* Adds an annotation to the specified class Annotations mark special properties of the given type
|
||||
* (like 'interface' or 'service')
|
||||
*
|
||||
* @param className The class name
|
||||
* @param annotation The name of the annotation without any brackets
|
||||
* @public
|
||||
@ -111,11 +114,11 @@ export const addAnnotation = function (className, annotation) {
|
||||
|
||||
/**
|
||||
* Adds a member to the specified class
|
||||
*
|
||||
* @param className The class name
|
||||
* @param member The full name of the member.
|
||||
* If the member is enclosed in <<brackets>> it is treated as an annotation
|
||||
* If the member is ending with a closing bracket ) it is treated as a method
|
||||
* Otherwise the member will be treated as a normal property
|
||||
* @param member The full name of the member. If the member is enclosed in <<brackets>> it is
|
||||
* treated as an annotation If the member is ending with a closing bracket ) it is treated as a
|
||||
* method Otherwise the member will be treated as a normal property
|
||||
* @public
|
||||
*/
|
||||
export const addMember = function (className, member) {
|
||||
@ -154,6 +157,7 @@ export const cleanupLabel = function (label) {
|
||||
|
||||
/**
|
||||
* Called by parser when a special node is found, e.g. a clickable element.
|
||||
*
|
||||
* @param ids Comma separated list of ids
|
||||
* @param className Class to add
|
||||
*/
|
||||
@ -169,6 +173,7 @@ export const setCssClass = function (ids, className) {
|
||||
|
||||
/**
|
||||
* Called by parser when a tooltip is found, e.g. a clickable element.
|
||||
*
|
||||
* @param ids Comma separated list of ids
|
||||
* @param tooltip Tooltip to add
|
||||
*/
|
||||
@ -183,6 +188,7 @@ const setTooltip = function (ids, tooltip) {
|
||||
|
||||
/**
|
||||
* Called by parser when a link is found. Adds the URL to the vertex data.
|
||||
*
|
||||
* @param ids Comma separated list of ids
|
||||
* @param linkStr URL to create a link for
|
||||
* @param target Target of the link, _blank by default as originally defined in the svgDraw.js file
|
||||
@ -206,6 +212,7 @@ export const setLink = function (ids, linkStr, target) {
|
||||
|
||||
/**
|
||||
* Called by parser when a click definition is found. Registers an event handler.
|
||||
*
|
||||
* @param ids Comma separated list of ids
|
||||
* @param functionName Function to be called on click
|
||||
* @param functionArgs Function args the function should be called with
|
||||
|
@ -25,7 +25,12 @@ const conf = {
|
||||
|
||||
/**
|
||||
* Function that adds the vertices found during parsing to the graph to be rendered.
|
||||
* @param {Object<string, { cssClasses: Array<string>; text: string; id: string; type: string; domId: string; }>} classes Object containing the vertices.
|
||||
*
|
||||
* @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) {
|
||||
@ -40,6 +45,7 @@ export const addClasses = function (classes, g) {
|
||||
|
||||
/**
|
||||
* Variable for storing the classes for the vertex
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
let cssClassStr = '';
|
||||
@ -130,8 +136,9 @@ export const addClasses = function (classes, g) {
|
||||
|
||||
/**
|
||||
* Add edges to graph based on parsed graph defninition
|
||||
* @param {Object} edges The edges to add to the graph
|
||||
* @param {Object} g The graph object
|
||||
*
|
||||
* @param relations
|
||||
* @param {object} g The graph object
|
||||
*/
|
||||
export const addRelations = function (relations, g) {
|
||||
let cnt = 0;
|
||||
@ -207,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 {
|
||||
@ -228,6 +236,7 @@ export const addRelations = function (relations, g) {
|
||||
|
||||
/**
|
||||
* Gets the ID with the same label as in the cache
|
||||
*
|
||||
* @param {string} label The label to look for
|
||||
* @returns {string} The resulting ID
|
||||
*/
|
||||
@ -241,7 +250,8 @@ const getGraphId = function (label) {
|
||||
|
||||
/**
|
||||
* Merges the value of `conf` with the passed `cnf`
|
||||
* @param {Object} cnf Config to merge
|
||||
*
|
||||
* @param {object} cnf Config to merge
|
||||
*/
|
||||
export const setConf = function (cnf) {
|
||||
const keys = Object.keys(cnf);
|
||||
@ -253,6 +263,7 @@ export const setConf = function (cnf) {
|
||||
|
||||
/**
|
||||
* Draws a flowchart in the tag with id: id based on the graph definition in text.
|
||||
*
|
||||
* @param {string} text
|
||||
* @param {string} id
|
||||
*/
|
||||
@ -504,8 +515,9 @@ export const draw = function (text, id) {
|
||||
|
||||
/**
|
||||
* Gets the arrow marker for a type index
|
||||
*
|
||||
* @param {number} type The type to look for
|
||||
* @returns {"aggregation" | "extension" | "composition" | "dependency"} The arrow marker
|
||||
* @returns {'aggregation' | 'extension' | 'composition' | 'dependency'} The arrow marker
|
||||
*/
|
||||
function getArrowMarker(type) {
|
||||
let marker;
|
||||
|
@ -20,6 +20,7 @@ const conf = {
|
||||
|
||||
/**
|
||||
* Gets the ID with the same label as in the cache
|
||||
*
|
||||
* @param {string} label The label to look for
|
||||
* @returns {string} The resulting ID
|
||||
*/
|
||||
@ -33,6 +34,7 @@ const getGraphId = function (label) {
|
||||
|
||||
/**
|
||||
* Setup arrow head and define the marker. The result is appended to the svg.
|
||||
*
|
||||
* @param {SVGSVGElement} elem The SVG element to append to
|
||||
*/
|
||||
const insertMarkers = function (elem) {
|
||||
@ -139,7 +141,8 @@ const insertMarkers = function (elem) {
|
||||
|
||||
/**
|
||||
* Merges the value of `conf` with the passed `cnf`
|
||||
* @param {Object} cnf Config to merge
|
||||
*
|
||||
* @param {object} cnf Config to merge
|
||||
*/
|
||||
export const setConf = function (cnf) {
|
||||
const keys = Object.keys(cnf);
|
||||
@ -151,6 +154,7 @@ export const setConf = function (cnf) {
|
||||
|
||||
/**
|
||||
* Draws a flowchart in the tag with id: id based on the graph definition in text.
|
||||
*
|
||||
* @param {string} text
|
||||
* @param {string} id
|
||||
*/
|
||||
|
@ -146,7 +146,10 @@ export const drawEdge = function (elem, path, relation, conf) {
|
||||
|
||||
/**
|
||||
* Renders a class diagram
|
||||
*
|
||||
* @param {SVGSVGElement} elem The element to draw it into
|
||||
* @param classDef
|
||||
* @param conf
|
||||
* @todo Add more information in the JSDOC here
|
||||
*/
|
||||
export const drawClass = function (elem, classDef, conf) {
|
||||
@ -389,10 +392,11 @@ const buildLegacyDisplay = function (text) {
|
||||
|
||||
/**
|
||||
* Adds a <tspan> for a member in a diagram
|
||||
*
|
||||
* @param {SVGElement} textEl The element to append to
|
||||
* @param {string} txt The member
|
||||
* @param {boolean} isFirst
|
||||
* @param {{ padding: string; textHeight: string; }} conf The configuration for the member
|
||||
* @param {{ padding: string; textHeight: string }} conf The configuration for the member
|
||||
*/
|
||||
const addTspan = function (textEl, txt, isFirst, conf) {
|
||||
let member = parseMember(txt);
|
||||
@ -410,9 +414,11 @@ const addTspan = function (textEl, txt, isFirst, conf) {
|
||||
|
||||
/**
|
||||
* Makes generics in typescript syntax
|
||||
*
|
||||
* @example <caption>Array of array of strings in typescript syntax</caption>
|
||||
* // returns "Array<Array<string>>"
|
||||
* parseGenericTypes("Array~Array~string~~");
|
||||
* // returns "Array<Array<string>>"
|
||||
* parseGenericTypes('Array~Array~string~~');
|
||||
*
|
||||
* @param {string} text The text to convert
|
||||
* @returns {string} The converted string
|
||||
*/
|
||||
@ -431,7 +437,8 @@ const parseGenericTypes = function (text) {
|
||||
|
||||
/**
|
||||
* Gives the styles for a classifier
|
||||
* @param {"+" | "-" | "#" | "~" | "*" | "$"} classifier The classifier string
|
||||
*
|
||||
* @param {'+' | '-' | '#' | '~' | '*' | '$'} classifier The classifier string
|
||||
* @returns {string} Styling for the classifier
|
||||
*/
|
||||
const parseClassifier = function (classifier) {
|
||||
|
@ -2,6 +2,7 @@ import DOMPurify from 'dompurify';
|
||||
|
||||
/**
|
||||
* Gets the number of lines in a string
|
||||
*
|
||||
* @param {string | undefined} s The string to check the lines for
|
||||
* @returns {number} The number of lines in that string
|
||||
*/
|
||||
@ -14,6 +15,7 @@ export const getRows = (s) => {
|
||||
|
||||
/**
|
||||
* Removes script tags from a text
|
||||
*
|
||||
* @param {string} txt The text to sanitize
|
||||
* @returns {string} The safer text
|
||||
*/
|
||||
@ -91,6 +93,7 @@ export const lineBreakRegex = /<br\s*\/?>/gi;
|
||||
|
||||
/**
|
||||
* Whether or not a text has any linebreaks
|
||||
*
|
||||
* @param {string} text The text to test
|
||||
* @returns {boolean} Whether or not the text has breaks
|
||||
*/
|
||||
@ -100,8 +103,9 @@ export const hasBreaks = (text) => {
|
||||
|
||||
/**
|
||||
* Splits on <br> tags
|
||||
*
|
||||
* @param {string} text Text to split
|
||||
* @returns {Array<string>} List of lines as strings
|
||||
* @returns {string[]} List of lines as strings
|
||||
*/
|
||||
export const splitBreaks = (text) => {
|
||||
return text.split(lineBreakRegex);
|
||||
@ -109,6 +113,7 @@ export const splitBreaks = (text) => {
|
||||
|
||||
/**
|
||||
* Converts placeholders to linebreaks in HTML
|
||||
*
|
||||
* @param {string} s HTML with placeholders
|
||||
* @returns {string} HTML with breaks instead of placeholders
|
||||
*/
|
||||
@ -118,6 +123,7 @@ const placeholderToBreak = (s) => {
|
||||
|
||||
/**
|
||||
* Opposite of `placeholderToBreak`, converts breaks to placeholders
|
||||
*
|
||||
* @param {string} s HTML string
|
||||
* @returns {string} String with placeholders
|
||||
*/
|
||||
@ -127,6 +133,7 @@ const breakToPlaceholder = (s) => {
|
||||
|
||||
/**
|
||||
* Gets the current URL
|
||||
*
|
||||
* @param {boolean} useAbsolute Whether to return the absolute URL or not
|
||||
* @returns {string} The current URL
|
||||
*/
|
||||
@ -148,6 +155,7 @@ const getUrl = (useAbsolute) => {
|
||||
|
||||
/**
|
||||
* Converts a string/boolean into a boolean
|
||||
*
|
||||
* @param {string | boolean} val String or boolean to convert
|
||||
* @returns {boolean} The result from the input
|
||||
*/
|
||||
|
@ -1,6 +1,3 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
import { log } from '../../logger';
|
||||
import mermaidAPI from '../../mermaidAPI';
|
||||
import * as configApi from '../../config';
|
||||
@ -49,6 +46,7 @@ const addAttributes = function (entityName, attribs) {
|
||||
|
||||
/**
|
||||
* Add a relationship
|
||||
*
|
||||
* @param entA The first entity in the relationship
|
||||
* @param rolA The role played by the first entity in relation to the second
|
||||
* @param entB The second entity in the relationship
|
||||
|
@ -11,6 +11,9 @@ const ERMarkers = {
|
||||
|
||||
/**
|
||||
* Put the markers into the svg DOM for later use with edge paths
|
||||
*
|
||||
* @param elem
|
||||
* @param conf
|
||||
*/
|
||||
const insertMarkers = function (elem, conf) {
|
||||
let marker;
|
||||
|
@ -11,9 +11,11 @@ import { configureSvgSize } from '../../utils';
|
||||
const conf = {};
|
||||
|
||||
/**
|
||||
* Allows the top-level API module to inject config specific to this renderer,
|
||||
* storing it in the local conf object. Note that generic config still needs to be
|
||||
* retrieved using getConfig() imported from the config module
|
||||
* Allows the top-level API module to inject config specific to this renderer, storing it in the
|
||||
* local conf object. Note that generic config still needs to be retrieved using getConfig()
|
||||
* imported from the config module
|
||||
*
|
||||
* @param cnf
|
||||
*/
|
||||
export const setConf = function (cnf) {
|
||||
const keys = Object.keys(cnf);
|
||||
@ -24,10 +26,11 @@ export const setConf = function (cnf) {
|
||||
|
||||
/**
|
||||
* Draw attributes for an entity
|
||||
* @param groupNode the svg group node for the entity
|
||||
* @param entityTextNode the svg node for the entity label text
|
||||
* @param attributes an array of attributes defined for the entity (each attribute has a type and a name)
|
||||
* @return the bounding box of the entity, after attributes have been added
|
||||
*
|
||||
* @param groupNode The svg group node for the entity
|
||||
* @param entityTextNode The svg node for the entity label text
|
||||
* @param attributes An array of attributes defined for the entity (each attribute has a type and a name)
|
||||
* @returns The bounding box of the entity, after attributes have been added
|
||||
*/
|
||||
const drawAttributes = (groupNode, entityTextNode, attributes) => {
|
||||
const heightPadding = conf.entityPadding / 3; // Padding internal to attribute boxes
|
||||
@ -269,10 +272,11 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
|
||||
|
||||
/**
|
||||
* Use D3 to construct the svg elements for the entities
|
||||
* @param svgNode the svg node that contains the diagram
|
||||
*
|
||||
* @param svgNode The svg node that contains the diagram
|
||||
* @param entities The entities to be drawn
|
||||
* @param graph The graph that contains the vertex and edge definitions post-layout
|
||||
* @return The first entity that was inserted
|
||||
* @returns The first entity that was inserted
|
||||
*/
|
||||
const drawEntities = function (svgNode, entities, graph) {
|
||||
const keys = Object.keys(entities);
|
||||
@ -356,9 +360,10 @@ const getEdgeName = function (rel) {
|
||||
|
||||
/**
|
||||
* Add each relationship to the graph
|
||||
* @param relationships the relationships to be added
|
||||
* @param g the graph
|
||||
* @return {Array} The array of relationships
|
||||
*
|
||||
* @param relationships The relationships to be added
|
||||
* @param g The graph
|
||||
* @returns {Array} The array of relationships
|
||||
*/
|
||||
const addRelationships = function (relationships, g) {
|
||||
relationships.forEach(function (r) {
|
||||
@ -370,10 +375,12 @@ const addRelationships = function (relationships, g) {
|
||||
let relCnt = 0;
|
||||
/**
|
||||
* Draw a relationship using edge information from the graph
|
||||
* @param svg the svg node
|
||||
* @param rel the relationship to draw in the svg
|
||||
* @param g the graph containing the edge information
|
||||
* @param insert the insertion point in the svg DOM (because relationships have markers that need to sit 'behind' opaque entity boxes)
|
||||
*
|
||||
* @param svg The svg node
|
||||
* @param rel The relationship to draw in the svg
|
||||
* @param g The graph containing the edge information
|
||||
* @param insert The insertion point in the svg DOM (because relationships have markers that need to
|
||||
* sit 'behind' opaque entity boxes)
|
||||
*/
|
||||
const drawRelationshipFromLayout = function (svg, rel, g, insert) {
|
||||
relCnt++;
|
||||
@ -502,8 +509,9 @@ const drawRelationshipFromLayout = function (svg, rel, g, insert) {
|
||||
|
||||
/**
|
||||
* Draw en E-R diagram in the tag with id: id based on the text definition of the diagram
|
||||
* @param text the text of the diagram
|
||||
* @param id the unique id of the DOM node that contains the diagram
|
||||
*
|
||||
* @param text The text of the diagram
|
||||
* @param id The unique id of the DOM node that contains the diagram
|
||||
*/
|
||||
export const draw = function (text, id) {
|
||||
log.info('Drawing ER diagram');
|
||||
|
@ -1,5 +1,10 @@
|
||||
import dagreD3 from 'dagre-d3';
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param bbox
|
||||
* @param node
|
||||
*/
|
||||
function question(parent, bbox, node) {
|
||||
const w = bbox.width;
|
||||
const h = bbox.height;
|
||||
@ -17,6 +22,11 @@ function question(parent, bbox, node) {
|
||||
return shapeSvg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param bbox
|
||||
* @param node
|
||||
*/
|
||||
function hexagon(parent, bbox, node) {
|
||||
const f = 4;
|
||||
const h = bbox.height;
|
||||
@ -37,6 +47,11 @@ function hexagon(parent, bbox, node) {
|
||||
return shapeSvg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param bbox
|
||||
* @param node
|
||||
*/
|
||||
function rect_left_inv_arrow(parent, bbox, node) {
|
||||
const w = bbox.width;
|
||||
const h = bbox.height;
|
||||
@ -54,6 +69,11 @@ function rect_left_inv_arrow(parent, bbox, node) {
|
||||
return shapeSvg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param bbox
|
||||
* @param node
|
||||
*/
|
||||
function lean_right(parent, bbox, node) {
|
||||
const w = bbox.width;
|
||||
const h = bbox.height;
|
||||
@ -70,6 +90,11 @@ function lean_right(parent, bbox, node) {
|
||||
return shapeSvg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param bbox
|
||||
* @param node
|
||||
*/
|
||||
function lean_left(parent, bbox, node) {
|
||||
const w = bbox.width;
|
||||
const h = bbox.height;
|
||||
@ -86,6 +111,11 @@ function lean_left(parent, bbox, node) {
|
||||
return shapeSvg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param bbox
|
||||
* @param node
|
||||
*/
|
||||
function trapezoid(parent, bbox, node) {
|
||||
const w = bbox.width;
|
||||
const h = bbox.height;
|
||||
@ -102,6 +132,11 @@ function trapezoid(parent, bbox, node) {
|
||||
return shapeSvg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param bbox
|
||||
* @param node
|
||||
*/
|
||||
function inv_trapezoid(parent, bbox, node) {
|
||||
const w = bbox.width;
|
||||
const h = bbox.height;
|
||||
@ -118,6 +153,11 @@ function inv_trapezoid(parent, bbox, node) {
|
||||
return shapeSvg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param bbox
|
||||
* @param node
|
||||
*/
|
||||
function rect_right_inv_arrow(parent, bbox, node) {
|
||||
const w = bbox.width;
|
||||
const h = bbox.height;
|
||||
@ -135,6 +175,11 @@ function rect_right_inv_arrow(parent, bbox, node) {
|
||||
return shapeSvg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param bbox
|
||||
* @param node
|
||||
*/
|
||||
function stadium(parent, bbox, node) {
|
||||
const h = bbox.height;
|
||||
const w = bbox.width + h / 4;
|
||||
@ -154,6 +199,11 @@ function stadium(parent, bbox, node) {
|
||||
return shapeSvg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param bbox
|
||||
* @param node
|
||||
*/
|
||||
function subroutine(parent, bbox, node) {
|
||||
const w = bbox.width;
|
||||
const h = bbox.height;
|
||||
@ -176,6 +226,11 @@ function subroutine(parent, bbox, node) {
|
||||
return shapeSvg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param bbox
|
||||
* @param node
|
||||
*/
|
||||
function cylinder(parent, bbox, node) {
|
||||
const w = bbox.width;
|
||||
const rx = w / 2;
|
||||
@ -239,6 +294,7 @@ function cylinder(parent, bbox, node) {
|
||||
return shapeSvg;
|
||||
}
|
||||
|
||||
/** @param render */
|
||||
export function addToRender(render) {
|
||||
render.shapes().question = question;
|
||||
render.shapes().hexagon = hexagon;
|
||||
@ -265,6 +321,7 @@ export function addToRender(render) {
|
||||
render.shapes().rect_right_inv_arrow = rect_right_inv_arrow;
|
||||
}
|
||||
|
||||
/** @param addShape */
|
||||
export function addToRenderV2(addShape) {
|
||||
addShape({ question });
|
||||
addShape({ hexagon });
|
||||
@ -291,6 +348,12 @@ export function addToRenderV2(addShape) {
|
||||
addShape({ rect_right_inv_arrow });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param w
|
||||
* @param h
|
||||
* @param points
|
||||
*/
|
||||
function insertPolygonShape(parent, w, h, points) {
|
||||
return parent
|
||||
.insert('polygon', ':first-child')
|
||||
|
@ -29,6 +29,7 @@ export const parseDirective = function (statement, context, type) {
|
||||
|
||||
/**
|
||||
* Function to lookup domId from id in the graph definition.
|
||||
*
|
||||
* @param id
|
||||
* @public
|
||||
*/
|
||||
@ -44,11 +45,13 @@ export const lookUpDomId = function (id) {
|
||||
|
||||
/**
|
||||
* Function called by parser when a node definition has been found
|
||||
* @param id
|
||||
*
|
||||
* @param _id
|
||||
* @param text
|
||||
* @param type
|
||||
* @param style
|
||||
* @param classes
|
||||
* @param dir
|
||||
*/
|
||||
export const addVertex = function (_id, text, type, style, classes, dir) {
|
||||
let txt;
|
||||
@ -110,8 +113,9 @@ export const addVertex = function (_id, text, type, style, classes, dir) {
|
||||
|
||||
/**
|
||||
* Function called by parser when a link/edge definition has been found
|
||||
* @param start
|
||||
* @param end
|
||||
*
|
||||
* @param _start
|
||||
* @param _end
|
||||
* @param type
|
||||
* @param linktext
|
||||
*/
|
||||
@ -152,8 +156,9 @@ export const addLink = function (_start, _end, type, linktext) {
|
||||
|
||||
/**
|
||||
* Updates a link's line interpolation algorithm
|
||||
* @param pos
|
||||
* @param interpolate
|
||||
*
|
||||
* @param positions
|
||||
* @param interp
|
||||
*/
|
||||
export const updateLinkInterpolate = function (positions, interp) {
|
||||
positions.forEach(function (pos) {
|
||||
@ -167,7 +172,8 @@ export const updateLinkInterpolate = function (positions, interp) {
|
||||
|
||||
/**
|
||||
* Updates a link with a style
|
||||
* @param pos
|
||||
*
|
||||
* @param positions
|
||||
* @param style
|
||||
*/
|
||||
export const updateLink = function (positions, style) {
|
||||
@ -204,6 +210,7 @@ export const addClass = function (id, style) {
|
||||
|
||||
/**
|
||||
* Called by parser when a graph definition is found, stores the direction of the chart.
|
||||
*
|
||||
* @param dir
|
||||
*/
|
||||
export const setDirection = function (dir) {
|
||||
@ -224,6 +231,7 @@ export const setDirection = function (dir) {
|
||||
|
||||
/**
|
||||
* Called by parser when a special node is found, e.g. a clickable element.
|
||||
*
|
||||
* @param ids Comma separated list of ids
|
||||
* @param className Class to add
|
||||
*/
|
||||
@ -298,8 +306,10 @@ const setClickFun = function (id, functionName, functionArgs) {
|
||||
|
||||
/**
|
||||
* Called by parser when a link is found. Adds the URL to the vertex data.
|
||||
*
|
||||
* @param ids Comma separated list of ids
|
||||
* @param linkStr URL to create a link for
|
||||
* @param target
|
||||
*/
|
||||
export const setLink = function (ids, linkStr, target) {
|
||||
ids.split(',').forEach(function (id) {
|
||||
@ -316,9 +326,10 @@ export const getTooltip = function (id) {
|
||||
|
||||
/**
|
||||
* Called by parser when a click definition is found. Registers an event handler.
|
||||
*
|
||||
* @param ids Comma separated list of ids
|
||||
* @param functionName Function to be called on click
|
||||
* @param tooltip Tooltip for the clickable element
|
||||
* @param functionArgs
|
||||
*/
|
||||
export const setClickEvent = function (ids, functionName, functionArgs) {
|
||||
ids.split(',').forEach(function (id) {
|
||||
@ -337,7 +348,8 @@ export const getDirection = function () {
|
||||
};
|
||||
/**
|
||||
* Retrieval function for fetching the found nodes after parsing has completed.
|
||||
* @returns {{}|*|vertices}
|
||||
*
|
||||
* @returns {{} | any | vertices}
|
||||
*/
|
||||
export const getVertices = function () {
|
||||
return vertices;
|
||||
@ -345,7 +357,8 @@ export const getVertices = function () {
|
||||
|
||||
/**
|
||||
* Retrieval function for fetching the found links after parsing has completed.
|
||||
* @returns {{}|*|edges}
|
||||
*
|
||||
* @returns {{} | any | edges}
|
||||
*/
|
||||
export const getEdges = function () {
|
||||
return edges;
|
||||
@ -353,7 +366,8 @@ export const getEdges = function () {
|
||||
|
||||
/**
|
||||
* Retrieval function for fetching the found class definitions after parsing has completed.
|
||||
* @returns {{}|*|classes}
|
||||
*
|
||||
* @returns {{} | any | classes}
|
||||
*/
|
||||
export const getClasses = function () {
|
||||
return classes;
|
||||
@ -396,6 +410,8 @@ funs.push(setupToolTips);
|
||||
|
||||
/**
|
||||
* Clears the internal graph db so that a new graph can be parsed.
|
||||
*
|
||||
* @param ver
|
||||
*/
|
||||
export const clear = function (ver) {
|
||||
vertices = {};
|
||||
@ -413,16 +429,17 @@ export const clear = function (ver) {
|
||||
export const setGen = (ver) => {
|
||||
version = ver || 'gen-1';
|
||||
};
|
||||
/**
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
/** @returns {string} */
|
||||
export const defaultStyle = function () {
|
||||
return 'fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;';
|
||||
};
|
||||
|
||||
/**
|
||||
* Clears the internal graph db so that a new graph can be parsed.
|
||||
*
|
||||
* @param _id
|
||||
* @param list
|
||||
* @param _title
|
||||
*/
|
||||
export const addSubGraph = function (_id, list, _title) {
|
||||
// console.log('addSubGraph', _id, list, _title);
|
||||
@ -431,6 +448,7 @@ export const addSubGraph = function (_id, list, _title) {
|
||||
if (_id === _title && _title.match(/\s/)) {
|
||||
id = undefined;
|
||||
}
|
||||
/** @param a */
|
||||
function uniq(a) {
|
||||
const prims = { boolean: {}, number: {}, string: {} };
|
||||
const objs = [];
|
||||
@ -474,9 +492,7 @@ export const addSubGraph = function (_id, list, _title) {
|
||||
|
||||
log.info('Adding', subGraph.id, subGraph.nodes, subGraph.dir);
|
||||
|
||||
/**
|
||||
* Deletes an id from all subgraphs
|
||||
*/
|
||||
/** Deletes an id from all subgraphs */
|
||||
// const del = _id => {
|
||||
// subGraphs.forEach(sg => {
|
||||
// const pos = sg.nodes.indexOf(_id);
|
||||
@ -701,6 +717,9 @@ const exists = (allSgs, _id) => {
|
||||
};
|
||||
/**
|
||||
* Deletes an id from all subgraphs
|
||||
*
|
||||
* @param sg
|
||||
* @param allSubgraphs
|
||||
*/
|
||||
const makeUniq = (sg, allSubgraphs) => {
|
||||
const res = [];
|
||||
|
@ -21,8 +21,10 @@ export const setConf = function (cnf) {
|
||||
|
||||
/**
|
||||
* Function that adds the vertices found during parsing to the graph to be rendered.
|
||||
*
|
||||
* @param vert Object containing the vertices.
|
||||
* @param g The graph that is to be drawn.
|
||||
* @param svgId
|
||||
*/
|
||||
export const addVertices = function (vert, g, svgId) {
|
||||
const svg = select(`[id="${svgId}"]`);
|
||||
@ -34,6 +36,7 @@ export const addVertices = function (vert, g, svgId) {
|
||||
|
||||
/**
|
||||
* Variable for storing the classes for the vertex
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
let classStr = 'default';
|
||||
@ -172,8 +175,9 @@ export const addVertices = function (vert, g, svgId) {
|
||||
|
||||
/**
|
||||
* Add edges to graph based on parsed graph defninition
|
||||
* @param {Object} edges The edges to add to the graph
|
||||
* @param {Object} g The graph object
|
||||
*
|
||||
* @param {object} edges The edges to add to the graph
|
||||
* @param {object} g The graph object
|
||||
*/
|
||||
export const addEdges = function (edges, g) {
|
||||
log.info('abc78 edges = ', edges);
|
||||
@ -317,7 +321,9 @@ export const addEdges = function (edges, g) {
|
||||
|
||||
/**
|
||||
* Returns the all the styles from classDef statements in the graph definition.
|
||||
* @returns {object} classDef styles
|
||||
*
|
||||
* @param text
|
||||
* @returns {object} ClassDef styles
|
||||
*/
|
||||
export const getClasses = function (text) {
|
||||
log.info('Extracting classes');
|
||||
@ -337,6 +343,7 @@ export const getClasses = function (text) {
|
||||
|
||||
/**
|
||||
* Draws a flowchart in the tag with id: id based on the graph definition in text.
|
||||
*
|
||||
* @param text
|
||||
* @param id
|
||||
*/
|
||||
|
@ -22,8 +22,10 @@ export const setConf = function (cnf) {
|
||||
|
||||
/**
|
||||
* Function that adds the vertices found in the graph definition to the graph to be rendered.
|
||||
*
|
||||
* @param vert Object containing the vertices.
|
||||
* @param g The graph that is to be drawn.
|
||||
* @param svgId
|
||||
*/
|
||||
export const addVertices = function (vert, g, svgId) {
|
||||
const svg = select(`[id="${svgId}"]`);
|
||||
@ -35,6 +37,7 @@ export const addVertices = function (vert, g, svgId) {
|
||||
|
||||
/**
|
||||
* Variable for storing the classes for the vertex
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
let classStr = 'default';
|
||||
@ -150,8 +153,9 @@ export const addVertices = function (vert, g, svgId) {
|
||||
|
||||
/**
|
||||
* Add edges to graph based on parsed graph defninition
|
||||
* @param {Object} edges The edges to add to the graph
|
||||
* @param {Object} g The graph object
|
||||
*
|
||||
* @param {object} edges The edges to add to the graph
|
||||
* @param {object} g The graph object
|
||||
*/
|
||||
export const addEdges = function (edges, g) {
|
||||
let cnt = 0;
|
||||
@ -257,7 +261,9 @@ export const addEdges = function (edges, g) {
|
||||
|
||||
/**
|
||||
* Returns the all the styles from classDef statements in the graph definition.
|
||||
* @returns {object} classDef styles
|
||||
*
|
||||
* @param text
|
||||
* @returns {object} ClassDef styles
|
||||
*/
|
||||
export const getClasses = function (text) {
|
||||
log.info('Extracting classes');
|
||||
@ -276,6 +282,7 @@ export const getClasses = function (text) {
|
||||
|
||||
/**
|
||||
* Draws a flowchart in the tag with id: id based on the graph definition in text.
|
||||
*
|
||||
* @param text
|
||||
* @param id
|
||||
*/
|
||||
|
@ -1,6 +1,22 @@
|
||||
/**
|
||||
* Returns the styles given options
|
||||
* @param {{ fontFamily: string; nodeTextColor: string; textColor: string; titleColor: string; mainBkg: string; nodeBorder: string; arrowheadColor: string; lineColor: string; edgeLabelBackground: string; clusterBkg: string; clusterBorder: string; tertiaryColor: string; border2: string; }} options The options for the styles
|
||||
*
|
||||
* @param {{
|
||||
* fontFamily: string;
|
||||
* nodeTextColor: string;
|
||||
* textColor: string;
|
||||
* titleColor: string;
|
||||
* mainBkg: string;
|
||||
* nodeBorder: string;
|
||||
* arrowheadColor: string;
|
||||
* lineColor: string;
|
||||
* edgeLabelBackground: string;
|
||||
* clusterBkg: string;
|
||||
* clusterBorder: string;
|
||||
* tertiaryColor: string;
|
||||
* border2: string;
|
||||
* }} options
|
||||
* The options for the styles
|
||||
* @returns {string} The resulting styles
|
||||
*/
|
||||
const getStyles = (options) =>
|
||||
|
@ -490,8 +490,9 @@ const compileTasks = function () {
|
||||
|
||||
/**
|
||||
* Called by parser when a link is found. Adds the URL to the vertex data.
|
||||
*
|
||||
* @param ids Comma separated list of ids
|
||||
* @param linkStr URL to create a link for
|
||||
* @param _linkStr URL to create a link for
|
||||
*/
|
||||
export const setLink = function (ids, _linkStr) {
|
||||
let linkStr = _linkStr;
|
||||
@ -511,6 +512,7 @@ export const setLink = function (ids, _linkStr) {
|
||||
|
||||
/**
|
||||
* Called by parser when a special node is found, e.g. a clickable element.
|
||||
*
|
||||
* @param ids Comma separated list of ids
|
||||
* @param className Class to add
|
||||
*/
|
||||
@ -560,7 +562,9 @@ const setClickFun = function (id, functionName, functionArgs) {
|
||||
};
|
||||
|
||||
/**
|
||||
* The callbackFunction is executed in a click event bound to the task with the specified id or the task's assigned text
|
||||
* The callbackFunction is executed in a click event bound to the task with the specified id or the
|
||||
* task's assigned text
|
||||
*
|
||||
* @param id The task's id
|
||||
* @param callbackFunction A function to be executed when clicked on the task or the task's text
|
||||
*/
|
||||
@ -587,6 +591,7 @@ const pushFun = function (id, callbackFunction) {
|
||||
|
||||
/**
|
||||
* Called by parser when a click definition is found. Registers an event handler.
|
||||
*
|
||||
* @param ids Comma separated list of ids
|
||||
* @param functionName Function to be called on click
|
||||
* @param functionArgs Function args the function should be called with
|
||||
@ -600,6 +605,7 @@ export const setClickEvent = function (ids, functionName, functionArgs) {
|
||||
|
||||
/**
|
||||
* Binds all functions previously added to fun (specified through click) to the element
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
export const bindFunctions = function (element) {
|
||||
@ -641,6 +647,11 @@ export default {
|
||||
isInvalidDate,
|
||||
};
|
||||
|
||||
/**
|
||||
* @param data
|
||||
* @param task
|
||||
* @param tags
|
||||
*/
|
||||
function getTaskTags(data, task, tags) {
|
||||
let matchFound = true;
|
||||
while (matchFound) {
|
||||
|
@ -71,6 +71,10 @@ export const draw = function (text, id) {
|
||||
|
||||
categories = checkUnique(categories);
|
||||
|
||||
/**
|
||||
* @param a
|
||||
* @param b
|
||||
*/
|
||||
function taskCompare(a, b) {
|
||||
const taskA = a.startTime;
|
||||
const taskB = b.startTime;
|
||||
@ -98,6 +102,11 @@ export const draw = function (text, id) {
|
||||
.attr('y', conf.titleTopMargin)
|
||||
.attr('class', 'titleText');
|
||||
|
||||
/**
|
||||
* @param tasks
|
||||
* @param pageWidth
|
||||
* @param pageHeight
|
||||
*/
|
||||
function makeGant(tasks, pageWidth, pageHeight) {
|
||||
const barHeight = conf.barHeight;
|
||||
const gap = barHeight + conf.barGap;
|
||||
@ -125,6 +134,15 @@ export const draw = function (text, id) {
|
||||
drawToday(leftPadding, topPadding, pageWidth, pageHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theArray
|
||||
* @param theGap
|
||||
* @param theTopPad
|
||||
* @param theSidePad
|
||||
* @param theBarHeight
|
||||
* @param theColorScale
|
||||
* @param w
|
||||
*/
|
||||
function drawRects(theArray, theGap, theTopPad, theSidePad, theBarHeight, theColorScale, w) {
|
||||
// Draw background rects covering the entire width of the graph, these form the section rows.
|
||||
svg
|
||||
@ -352,6 +370,16 @@ export const draw = function (text, id) {
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @param theGap
|
||||
* @param theTopPad
|
||||
* @param theSidePad
|
||||
* @param w
|
||||
* @param h
|
||||
* @param tasks
|
||||
* @param excludes
|
||||
* @param includes
|
||||
*/
|
||||
function drawExcludeDays(theGap, theTopPad, theSidePad, w, h, tasks, excludes, includes) {
|
||||
const minTime = tasks.reduce(
|
||||
(min, { startTime }) => (min ? Math.min(min, startTime) : startTime),
|
||||
@ -414,6 +442,12 @@ export const draw = function (text, id) {
|
||||
.attr('class', 'exclude-range');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theSidePad
|
||||
* @param theTopPad
|
||||
* @param w
|
||||
* @param h
|
||||
*/
|
||||
function makeGrid(theSidePad, theTopPad, w, h) {
|
||||
let bottomXAxis = axisBottom(timeScale)
|
||||
.tickSize(-h + theTopPad + conf.gridLineStartPadding)
|
||||
@ -450,6 +484,10 @@ export const draw = function (text, id) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theGap
|
||||
* @param theTopPad
|
||||
*/
|
||||
function vertLabels(theGap, theTopPad) {
|
||||
const numOccurances = [];
|
||||
let prevGap = 0;
|
||||
@ -503,6 +541,12 @@ export const draw = function (text, id) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theSidePad
|
||||
* @param theTopPad
|
||||
* @param w
|
||||
* @param h
|
||||
*/
|
||||
function drawToday(theSidePad, theTopPad, w, h) {
|
||||
const todayMarker = ganttDb.getTodayMarker();
|
||||
if (todayMarker === 'off') {
|
||||
@ -525,7 +569,12 @@ export const draw = function (text, id) {
|
||||
}
|
||||
}
|
||||
|
||||
// from this stackexchange question: http://stackoverflow.com/questions/1890203/unique-for-arrays-in-javascript
|
||||
/**
|
||||
* From this stackexchange question:
|
||||
* http://stackoverflow.com/questions/1890203/unique-for-arrays-in-javascript
|
||||
*
|
||||
* @param arr
|
||||
*/
|
||||
function checkUnique(arr) {
|
||||
const hash = {};
|
||||
const result = [];
|
||||
@ -540,7 +589,12 @@ export const draw = function (text, id) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// from this stackexchange question: http://stackoverflow.com/questions/14227981/count-how-many-strings-in-an-array-have-duplicates-in-the-same-array
|
||||
/**
|
||||
* From this stackexchange question:
|
||||
* http://stackoverflow.com/questions/14227981/count-how-many-strings-in-an-array-have-duplicates-in-the-same-array
|
||||
*
|
||||
* @param arr
|
||||
*/
|
||||
function getCounts(arr) {
|
||||
let i = arr.length; // const to loop over
|
||||
const obj = {}; // obj to store results
|
||||
@ -550,7 +604,12 @@ export const draw = function (text, id) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
// get specific from everything
|
||||
/**
|
||||
* Get specific from everything
|
||||
*
|
||||
* @param word
|
||||
* @param arr
|
||||
*/
|
||||
function getCount(word, arr) {
|
||||
return getCounts(arr)[word] || 0;
|
||||
}
|
||||
|
@ -11,6 +11,10 @@ function getId() {
|
||||
return random({ length: 7 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param currentCommit
|
||||
* @param otherCommit
|
||||
*/
|
||||
function isfastforwardable(currentCommit, otherCommit) {
|
||||
log.debug('Entering isfastforwardable:', currentCommit.id, otherCommit.id);
|
||||
while (currentCommit.seq <= otherCommit.seq && currentCommit !== otherCommit) {
|
||||
@ -30,6 +34,10 @@ function isfastforwardable(currentCommit, otherCommit) {
|
||||
return currentCommit.id === otherCommit.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param currentCommit
|
||||
* @param otherCommit
|
||||
*/
|
||||
function isReachableFrom(currentCommit, otherCommit) {
|
||||
const currentSeq = currentCommit.seq;
|
||||
const otherSeq = otherCommit.seq;
|
||||
@ -37,6 +45,10 @@ function isReachableFrom(currentCommit, otherCommit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list
|
||||
* @param fn
|
||||
*/
|
||||
function uniqBy(list, fn) {
|
||||
const recordMap = Object.create(null);
|
||||
return list.reduce((out, item) => {
|
||||
@ -138,6 +150,11 @@ export const reset = function (commitRef) {
|
||||
branches[curBranch] = commit.id;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param arr
|
||||
* @param key
|
||||
* @param newval
|
||||
*/
|
||||
function upsert(arr, key, newval) {
|
||||
const index = arr.indexOf(key);
|
||||
if (index === -1) {
|
||||
@ -147,6 +164,7 @@ function upsert(arr, key, newval) {
|
||||
}
|
||||
}
|
||||
|
||||
/** @param commitArr */
|
||||
function prettyPrintCommitHistory(commitArr) {
|
||||
const commit = commitArr.reduce((out, commit) => {
|
||||
if (out.seq > commit.seq) return out;
|
||||
|
@ -30,6 +30,7 @@ export const setConf = function (c) {
|
||||
apiConfig = c;
|
||||
};
|
||||
|
||||
/** @param svg */
|
||||
function svgCreateDefs(svg) {
|
||||
svg
|
||||
.append('defs')
|
||||
@ -52,6 +53,12 @@ function svgCreateDefs(svg) {
|
||||
.html('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param svg
|
||||
* @param points
|
||||
* @param colorIdx
|
||||
* @param interpolate
|
||||
*/
|
||||
function svgDrawLine(svg, points, colorIdx, interpolate) {
|
||||
const curve = interpolateToCurve(interpolate, curveBasis);
|
||||
const color = config.branchColors[colorIdx % config.branchColors.length];
|
||||
@ -72,7 +79,12 @@ function svgDrawLine(svg, points, colorIdx, interpolate) {
|
||||
.style('fill', 'none');
|
||||
}
|
||||
|
||||
// Pass in the element and its pre-transform coords
|
||||
/**
|
||||
* Pass in the element and its pre-transform coords
|
||||
*
|
||||
* @param element
|
||||
* @param coords
|
||||
*/
|
||||
function getElementCoords(element, coords) {
|
||||
coords = coords || element.node().getBBox();
|
||||
const ctm = element.node().getCTM();
|
||||
@ -86,6 +98,13 @@ function getElementCoords(element, coords) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param svg
|
||||
* @param fromId
|
||||
* @param toId
|
||||
* @param direction
|
||||
* @param color
|
||||
*/
|
||||
function svgDrawLineForCommits(svg, fromId, toId, direction, color) {
|
||||
log.debug('svgDrawLineForCommits: ', fromId, toId);
|
||||
const fromBbox = getElementCoords(svg.select('#node-' + fromId + ' circle'));
|
||||
@ -190,10 +209,20 @@ function svgDrawLineForCommits(svg, fromId, toId, direction, color) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param svg
|
||||
* @param selector
|
||||
*/
|
||||
function cloneNode(svg, selector) {
|
||||
return svg.select(selector).node().cloneNode(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param svg
|
||||
* @param commitid
|
||||
* @param branches
|
||||
* @param direction
|
||||
*/
|
||||
function renderCommitHistory(svg, commitid, branches, direction) {
|
||||
let commit;
|
||||
const numCommits = Object.keys(allCommitsDict).length;
|
||||
@ -276,6 +305,12 @@ function renderCommitHistory(svg, commitid, branches, direction) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param svg
|
||||
* @param commit
|
||||
* @param direction
|
||||
* @param branchColor
|
||||
*/
|
||||
function renderLines(svg, commit, direction, branchColor) {
|
||||
branchColor = branchColor || 0;
|
||||
while (commit.seq > 0 && !commit.lineDrawn) {
|
||||
|
@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Created by knut on 15-01-14.
|
||||
*/
|
||||
/** Created by knut on 15-01-14. */
|
||||
import { log } from '../../logger';
|
||||
|
||||
var message = '';
|
||||
|
@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Created by knut on 14-12-11.
|
||||
*/
|
||||
/** Created by knut on 14-12-11. */
|
||||
import { select } from 'd3';
|
||||
import db from './infoDb';
|
||||
import infoParser from './parser/info';
|
||||
@ -17,16 +15,18 @@ export const setConf = function (cnf) {
|
||||
|
||||
/**
|
||||
* Draws a an info picture in the tag with id: id based on the graph definition in text.
|
||||
* @param text
|
||||
* @param id
|
||||
*
|
||||
* @param {any} text
|
||||
* @param {any} id
|
||||
* @param {any} version
|
||||
*/
|
||||
export const draw = (txt, id, ver) => {
|
||||
export const draw = (text, id, version) => {
|
||||
try {
|
||||
const parser = infoParser.parser;
|
||||
parser.yy = db;
|
||||
log.debug('Renering info diagram\n' + txt);
|
||||
log.debug('Renering info diagram\n' + text);
|
||||
// Parse the graph definition
|
||||
parser.parse(txt);
|
||||
parser.parse(text);
|
||||
log.debug('Parsed info diagram');
|
||||
// Fetch the default direction, use TD if none was found
|
||||
const svg = select('#' + id);
|
||||
@ -39,7 +39,7 @@ export const draw = (txt, id, ver) => {
|
||||
.attr('class', 'version')
|
||||
.attr('font-size', '32px')
|
||||
.style('text-anchor', 'middle')
|
||||
.text('v ' + ver);
|
||||
.text('v ' + version);
|
||||
|
||||
svg.attr('height', 100);
|
||||
svg.attr('width', 400);
|
||||
|
@ -1,6 +1,3 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
import { log } from '../../logger';
|
||||
import mermaidAPI from '../../mermaidAPI';
|
||||
import * as configApi from '../../config';
|
||||
|
@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Created by AshishJ on 11-09-2019.
|
||||
*/
|
||||
/** Created by AshishJ on 11-09-2019. */
|
||||
import { select, scaleOrdinal, pie as d3pie, arc } from 'd3';
|
||||
import pieData from './pieDb';
|
||||
import pieParser from './parser/pie';
|
||||
@ -12,6 +10,7 @@ let conf = configApi.getConfig();
|
||||
|
||||
/**
|
||||
* Draws a Pie Chart with the data given in text.
|
||||
*
|
||||
* @param text
|
||||
* @param id
|
||||
*/
|
||||
|
@ -251,6 +251,10 @@ export const addALink = function (actorId, text) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} actor
|
||||
* @param {any} links
|
||||
*/
|
||||
function insertLinks(actor, links) {
|
||||
if (actor.links == null) {
|
||||
actor.links = links;
|
||||
@ -275,6 +279,10 @@ export const addProperties = function (actorId, text) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} actor
|
||||
* @param {any} properties
|
||||
*/
|
||||
function insertProperties(actor, properties) {
|
||||
if (actor.properties == null) {
|
||||
actor.properties = properties;
|
||||
|
@ -97,6 +97,7 @@ export const bounds = {
|
||||
updateBounds: function (startx, starty, stopx, stopy) {
|
||||
const _self = this;
|
||||
let cnt = 0;
|
||||
/** @param {any} type */
|
||||
function updateFn(type) {
|
||||
return function updateItemBounds(item) {
|
||||
cnt++;
|
||||
@ -198,8 +199,11 @@ export const bounds = {
|
||||
|
||||
/**
|
||||
* Draws an note in the diagram with the attached line
|
||||
* @param elem - The diagram to draw to.
|
||||
* @param noteModel:{x: number, y: number, message: string, width: number} - startx: x axis start position, verticalPos: y axis position, messsage: the message to be shown, width: Set this with a custom width to override the default configured width.
|
||||
*
|
||||
* @param {any} elem - The diagram to draw to.
|
||||
* @param {{ x: number; y: number; message: string; width: number }} noteModel - Startx: x axis
|
||||
* start position, verticalPos: y axis position, messsage: the message to be shown, width: Set
|
||||
* this with a custom width to override the default configured width.
|
||||
*/
|
||||
const drawNote = function (elem, noteModel) {
|
||||
bounds.bumpVerticalPos(conf.boxMargin);
|
||||
@ -268,8 +272,9 @@ const actorFont = (cnf) => {
|
||||
|
||||
/**
|
||||
* Draws a message
|
||||
* @param g - the parent of the message element
|
||||
* @param msgModel - the model containing fields describing a message
|
||||
*
|
||||
* @param {any} g - The parent of the message element
|
||||
* @param {any} msgModel - The model containing fields describing a message
|
||||
*/
|
||||
const drawMessage = function (g, msgModel) {
|
||||
bounds.bumpVerticalPos(10);
|
||||
@ -499,6 +504,13 @@ const activationBounds = function (actor, actors) {
|
||||
return [left, right];
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} loopWidths
|
||||
* @param {any} msg
|
||||
* @param {any} preMargin
|
||||
* @param {any} postMargin
|
||||
* @param {any} addLoopFn
|
||||
*/
|
||||
function adjustLoopHeightForWrap(loopWidths, msg, preMargin, postMargin, addLoopFn) {
|
||||
bounds.bumpVerticalPos(preMargin);
|
||||
let heightAdjust = postMargin;
|
||||
@ -521,8 +533,9 @@ function adjustLoopHeightForWrap(loopWidths, msg, preMargin, postMargin, addLoop
|
||||
|
||||
/**
|
||||
* Draws a sequenceDiagram in the tag with id: id based on the graph definition in text.
|
||||
* @param text
|
||||
* @param id
|
||||
*
|
||||
* @param {any} text
|
||||
* @param {any} id
|
||||
*/
|
||||
export const draw = function (text, id) {
|
||||
conf = configApi.getConfig().sequence;
|
||||
@ -556,6 +569,10 @@ export const draw = function (text, id) {
|
||||
svgDraw.insertArrowFilledHead(diagram);
|
||||
svgDraw.insertSequenceNumber(diagram);
|
||||
|
||||
/**
|
||||
* @param {any} msg
|
||||
* @param {any} verticalPos
|
||||
*/
|
||||
function activeEnd(msg, verticalPos) {
|
||||
const activationData = bounds.endActivation(msg);
|
||||
if (activationData.starty + 18 > verticalPos) {
|
||||
@ -769,14 +786,14 @@ export const draw = function (text, id) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the max message width of each actor, supports signals (messages, loops)
|
||||
* and notes.
|
||||
* Retrieves the max message width of each actor, supports signals (messages, loops) and notes.
|
||||
*
|
||||
* It will enumerate each given message, and will determine its text width, in relation
|
||||
* to the actor it originates from, and destined to.
|
||||
* It will enumerate each given message, and will determine its text width, in relation to the actor
|
||||
* it originates from, and destined to.
|
||||
*
|
||||
* @param actors - The actors map
|
||||
* @param messages - A list of message objects to iterate
|
||||
* @param {any} actors - The actors map
|
||||
* @param {Array} messages - A list of message objects to iterate
|
||||
* @returns {any}
|
||||
*/
|
||||
const getMaxMessageWidthPerActor = function (actors, messages) {
|
||||
const maxMessageWidthPerActor = {};
|
||||
@ -888,14 +905,13 @@ const getRequiredPopupWidth = function (actor) {
|
||||
};
|
||||
|
||||
/**
|
||||
* This will calculate the optimal margin for each given actor, for a given
|
||||
* actor->messageWidth map.
|
||||
* This will calculate the optimal margin for each given actor, for a given actor->messageWidth map.
|
||||
*
|
||||
* An actor's margin is determined by the width of the actor, the width of the
|
||||
* largest message that originates from it, and the configured conf.actorMargin.
|
||||
* An actor's margin is determined by the width of the actor, the width of the largest message that
|
||||
* originates from it, and the configured conf.actorMargin.
|
||||
*
|
||||
* @param actors - The actors map to calculate margins for
|
||||
* @param actorToMessageWidth - A map of actor key -> max message width it holds
|
||||
* @param {any} actors - The actors map to calculate margins for
|
||||
* @param {any} actorToMessageWidth - A map of actor key -> max message width it holds
|
||||
*/
|
||||
const calculateActorMargins = function (actors, actorToMessageWidth) {
|
||||
let maxHeight = 0;
|
||||
|
@ -275,6 +275,14 @@ export const drawText = function (elem, textData) {
|
||||
};
|
||||
|
||||
export const drawLabel = function (elem, txtObject) {
|
||||
/**
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} cut
|
||||
* @returns {any}
|
||||
*/
|
||||
function genPoints(x, y, width, height, cut) {
|
||||
return (
|
||||
x +
|
||||
@ -320,9 +328,10 @@ export const fixLifeLineHeights = (diagram, bounds) => {
|
||||
|
||||
/**
|
||||
* Draws an actor in the diagram with the attached line
|
||||
* @param elem - The diagram we'll draw to.
|
||||
* @param actor - The actor to draw.
|
||||
* @param conf - drawText implementation discriminator object
|
||||
*
|
||||
* @param {any} elem - The diagram we'll draw to.
|
||||
* @param {any} actor - The actor to draw.
|
||||
* @param {any} conf - DrawText implementation discriminator object
|
||||
*/
|
||||
const drawActorTypeParticipant = function (elem, actor, conf) {
|
||||
const center = actor.x + actor.width / 2;
|
||||
@ -494,11 +503,12 @@ export const anchorElement = function (elem) {
|
||||
};
|
||||
/**
|
||||
* Draws an activation in the diagram
|
||||
* @param elem - element to append activation rect.
|
||||
* @param bounds - activation box bounds.
|
||||
* @param verticalPos - precise y cooridnate of bottom activation box edge.
|
||||
* @param conf - sequence diagram config object.
|
||||
* @param actorActivations - number of activations on the actor.
|
||||
*
|
||||
* @param {any} elem - Element to append activation rect.
|
||||
* @param {any} bounds - Activation box bounds.
|
||||
* @param {any} verticalPos - Precise y cooridnate of bottom activation box edge.
|
||||
* @param {any} conf - Sequence diagram config object.
|
||||
* @param {any} actorActivations - Number of activations on the actor.
|
||||
*/
|
||||
export const drawActivation = function (elem, bounds, verticalPos, conf, actorActivations) {
|
||||
const rect = getNoteRect();
|
||||
@ -513,10 +523,12 @@ export const drawActivation = function (elem, bounds, verticalPos, conf, actorAc
|
||||
|
||||
/**
|
||||
* Draws a loop in the diagram
|
||||
* @param elem - elemenet to append the loop to.
|
||||
* @param loopModel - loopModel of the given loop.
|
||||
* @param labelText - Text within the loop.
|
||||
* @param conf - diagrom configuration
|
||||
*
|
||||
* @param {any} elem - Elemenet to append the loop to.
|
||||
* @param {any} loopModel - LoopModel of the given loop.
|
||||
* @param {any} labelText - Text within the loop.
|
||||
* @param {any} conf - Diagrom configuration
|
||||
* @returns {any}
|
||||
*/
|
||||
export const drawLoop = function (elem, loopModel, labelText, conf) {
|
||||
const {
|
||||
@ -613,8 +625,9 @@ export const drawLoop = function (elem, loopModel, labelText, conf) {
|
||||
|
||||
/**
|
||||
* Draws a background rectangle
|
||||
* @param elem diagram (reference for bounds)
|
||||
* @param bounds shape of the rectangle
|
||||
*
|
||||
* @param {any} elem Diagram (reference for bounds)
|
||||
* @param {any} bounds Shape of the rectangle
|
||||
*/
|
||||
export const drawBackgroundRect = function (elem, bounds) {
|
||||
const rectElem = drawRect(elem, {
|
||||
@ -675,6 +688,8 @@ export const insertClockIcon = function (elem) {
|
||||
|
||||
/**
|
||||
* Setup arrow head and define the marker. The result is appended to the svg.
|
||||
*
|
||||
* @param elem
|
||||
*/
|
||||
export const insertArrowHead = function (elem) {
|
||||
elem
|
||||
@ -692,6 +707,8 @@ export const insertArrowHead = function (elem) {
|
||||
};
|
||||
/**
|
||||
* Setup arrow head and define the marker. The result is appended to the svg.
|
||||
*
|
||||
* @param {any} elem
|
||||
*/
|
||||
export const insertArrowFilledHead = function (elem) {
|
||||
elem
|
||||
@ -708,6 +725,8 @@ export const insertArrowFilledHead = function (elem) {
|
||||
};
|
||||
/**
|
||||
* Setup node number. The result is appended to the svg.
|
||||
*
|
||||
* @param {any} elem
|
||||
*/
|
||||
export const insertSequenceNumber = function (elem) {
|
||||
elem
|
||||
@ -727,6 +746,8 @@ export const insertSequenceNumber = function (elem) {
|
||||
};
|
||||
/**
|
||||
* Setup arrow head and define the marker. The result is appended to the svg.
|
||||
*
|
||||
* @param {any} elem
|
||||
*/
|
||||
export const insertArrowCrossHead = function (elem) {
|
||||
const defs = elem.append('defs');
|
||||
@ -791,6 +812,15 @@ export const getNoteRect = function () {
|
||||
};
|
||||
|
||||
const _drawTextCandidateFunc = (function () {
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {any} g
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} textAttrs
|
||||
*/
|
||||
function byText(content, g, x, y, width, height, textAttrs) {
|
||||
const text = g
|
||||
.append('text')
|
||||
@ -801,6 +831,16 @@ const _drawTextCandidateFunc = (function () {
|
||||
_setTextAttrs(text, textAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {any} g
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} textAttrs
|
||||
* @param {any} conf
|
||||
*/
|
||||
function byTspan(content, g, x, y, width, height, textAttrs, conf) {
|
||||
const { actorFontSize, actorFontFamily, actorFontWeight } = conf;
|
||||
|
||||
@ -830,6 +870,16 @@ const _drawTextCandidateFunc = (function () {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {any} g
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} textAttrs
|
||||
* @param {any} conf
|
||||
*/
|
||||
function byFo(content, g, x, y, width, height, textAttrs, conf) {
|
||||
const s = g.append('switch');
|
||||
const f = s
|
||||
@ -856,6 +906,10 @@ const _drawTextCandidateFunc = (function () {
|
||||
_setTextAttrs(text, textAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} toText
|
||||
* @param {any} fromTextAttrsDict
|
||||
*/
|
||||
function _setTextAttrs(toText, fromTextAttrsDict) {
|
||||
for (const key in fromTextAttrsDict) {
|
||||
if (fromTextAttrsDict.hasOwnProperty(key)) { // eslint-disable-line
|
||||
@ -870,6 +924,15 @@ const _drawTextCandidateFunc = (function () {
|
||||
})();
|
||||
|
||||
const _drawMenuItemTextCandidateFunc = (function () {
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {any} g
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} textAttrs
|
||||
*/
|
||||
function byText(content, g, x, y, width, height, textAttrs) {
|
||||
const text = g
|
||||
.append('text')
|
||||
@ -880,6 +943,16 @@ const _drawMenuItemTextCandidateFunc = (function () {
|
||||
_setTextAttrs(text, textAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {any} g
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} textAttrs
|
||||
* @param {any} conf
|
||||
*/
|
||||
function byTspan(content, g, x, y, width, height, textAttrs, conf) {
|
||||
const { actorFontSize, actorFontFamily, actorFontWeight } = conf;
|
||||
|
||||
@ -905,6 +978,16 @@ const _drawMenuItemTextCandidateFunc = (function () {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {any} g
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} textAttrs
|
||||
* @param {any} conf
|
||||
*/
|
||||
function byFo(content, g, x, y, width, height, textAttrs, conf) {
|
||||
const s = g.append('switch');
|
||||
const f = s
|
||||
@ -931,6 +1014,10 @@ const _drawMenuItemTextCandidateFunc = (function () {
|
||||
_setTextAttrs(text, textAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} toText
|
||||
* @param {any} fromTextAttrsDict
|
||||
*/
|
||||
function _setTextAttrs(toText, fromTextAttrsDict) {
|
||||
for (const key in fromTextAttrsDict) {
|
||||
if (fromTextAttrsDict.hasOwnProperty(key)) { // eslint-disable-line
|
||||
|
@ -6,10 +6,10 @@ import common from '../common/common';
|
||||
import { getConfig } from '../../config';
|
||||
import { log } from '../../logger';
|
||||
|
||||
// let conf;
|
||||
|
||||
/**
|
||||
* Draws a start state as a black circle
|
||||
*
|
||||
* @param {any} g
|
||||
*/
|
||||
export const drawStartState = (g) =>
|
||||
g
|
||||
@ -23,6 +23,8 @@ export const drawStartState = (g) =>
|
||||
|
||||
/**
|
||||
* Draws a start state as a black circle
|
||||
*
|
||||
* @param {any} g
|
||||
*/
|
||||
export const drawDivider = (g) =>
|
||||
g
|
||||
@ -37,6 +39,9 @@ export const drawDivider = (g) =>
|
||||
|
||||
/**
|
||||
* Draws a an end state as a black circle
|
||||
*
|
||||
* @param {any} g
|
||||
* @param {any} stateDef
|
||||
*/
|
||||
export const drawSimpleState = (g, stateDef) => {
|
||||
const state = g
|
||||
@ -60,8 +65,10 @@ export const drawSimpleState = (g, stateDef) => {
|
||||
|
||||
/**
|
||||
* Draws a state with descriptions
|
||||
* @param {*} g
|
||||
* @param {*} stateDef
|
||||
*
|
||||
* @param {any} g
|
||||
* @param {any} stateDef
|
||||
* @returns
|
||||
*/
|
||||
export const drawDescrState = (g, stateDef) => {
|
||||
const addTspan = function (textEl, txt, isFirst) {
|
||||
@ -128,15 +135,14 @@ export const drawDescrState = (g, stateDef) => {
|
||||
return g;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds the creates a box around the existing content and adds a
|
||||
* panel for the id on top of the content.
|
||||
*/
|
||||
/** Adds the creates a box around the existing content and adds a panel for the id on top of the content. */
|
||||
/**
|
||||
* Function that creates an title row and a frame around a substate for a composit state diagram.
|
||||
* The function returns a new d3 svg object with updated width and height properties;
|
||||
* @param {*} g The d3 svg object for the substate to framed
|
||||
* @param {*} stateDef The info about the
|
||||
*
|
||||
* @param {any} g The d3 svg object for the substate to framed
|
||||
* @param {any} stateDef The info about the
|
||||
* @param {any} altBkg
|
||||
*/
|
||||
export const addTitleAndBox = (g, stateDef, altBkg) => {
|
||||
const pad = getConfig().state.padding;
|
||||
@ -337,6 +343,7 @@ const _drawLongText = (_text, x, y, g) => {
|
||||
|
||||
/**
|
||||
* Draws a note to the diagram
|
||||
*
|
||||
* @param text - The text of the given note.
|
||||
* @param g - The element the note is attached to.
|
||||
*/
|
||||
@ -354,10 +361,11 @@ export const drawNote = (text, g) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* Starting point for drawing a state. The function finds out the specifics
|
||||
* about the state and renders with approprtiate function.
|
||||
* @param {*} elem
|
||||
* @param {*} stateDef
|
||||
* Starting point for drawing a state. The function finds out the specifics about the state and
|
||||
* renders with approprtiate function.
|
||||
*
|
||||
* @param {any} elem
|
||||
* @param {any} stateDef
|
||||
*/
|
||||
|
||||
export const drawState = function (elem, stateDef) {
|
||||
|
@ -117,10 +117,12 @@ let endCnt = 0; // eslint-disable-line
|
||||
|
||||
/**
|
||||
* Function called by parser when a node definition has been found.
|
||||
* @param id
|
||||
* @param text
|
||||
* @param type
|
||||
* @param style
|
||||
*
|
||||
* @param {any} id
|
||||
* @param {any} type
|
||||
* @param {any} doc
|
||||
* @param {any} descr
|
||||
* @param {any} note
|
||||
*/
|
||||
export const addState = function (id, type, doc, descr, note) {
|
||||
if (typeof currentDocument.states[id] === 'undefined') {
|
||||
|
@ -20,7 +20,9 @@ let nodeDb = {};
|
||||
|
||||
/**
|
||||
* Returns the all the styles from classDef statements in the graph definition.
|
||||
* @returns {object} classDef styles
|
||||
*
|
||||
* @param {any} text
|
||||
* @returns {object} ClassDef styles
|
||||
*/
|
||||
export const getClasses = function (text) {
|
||||
log.trace('Extracting classes');
|
||||
@ -227,8 +229,9 @@ const getDir = (nodes, defaultDir) => {
|
||||
};
|
||||
/**
|
||||
* Draws a flowchart in the tag with id: id based on the graph definition in text.
|
||||
* @param text
|
||||
* @param id
|
||||
*
|
||||
* @param {any} text
|
||||
* @param {any} id
|
||||
*/
|
||||
export const draw = function (text, id) {
|
||||
log.info('Drawing state diagram (v2)', id);
|
||||
|
@ -19,10 +19,10 @@ const transformationLog = {};
|
||||
|
||||
export const setConf = function () {};
|
||||
|
||||
// Todo optimize
|
||||
|
||||
/**
|
||||
* Setup arrow head and define the marker. The result is appended to the svg.
|
||||
*
|
||||
* @param {any} elem
|
||||
*/
|
||||
const insertMarkers = function (elem) {
|
||||
elem
|
||||
@ -40,8 +40,9 @@ const insertMarkers = function (elem) {
|
||||
|
||||
/**
|
||||
* Draws a flowchart in the tag with id: id based on the graph definition in text.
|
||||
* @param text
|
||||
* @param id
|
||||
*
|
||||
* @param {any} text
|
||||
* @param {any} id
|
||||
*/
|
||||
export const draw = function (text, id) {
|
||||
conf = getConfig().state;
|
||||
@ -90,7 +91,7 @@ const getLabelWidth = (text) => {
|
||||
};
|
||||
|
||||
const renderDoc = (doc, diagram, parentId, altBkg) => {
|
||||
// // Layout graph, Create a new directed graph
|
||||
// Layout graph, Create a new directed graph
|
||||
const graph = new graphlib.Graph({
|
||||
compound: true,
|
||||
multigraph: true,
|
||||
|
@ -17,6 +17,7 @@ export const setConf = function (cnf) {
|
||||
|
||||
const actors = {};
|
||||
|
||||
/** @param {any} diagram */
|
||||
function drawActorLegend(diagram) {
|
||||
const conf = getConfig().journey;
|
||||
// Draw the actors
|
||||
@ -140,6 +141,7 @@ export const bounds = {
|
||||
const conf = getConfig().journey;
|
||||
const _self = this;
|
||||
let cnt = 0;
|
||||
/** @param {any} type */
|
||||
function updateFn(type) {
|
||||
return function updateItemBounds(item) {
|
||||
cnt++;
|
||||
|
@ -51,6 +51,7 @@ export const drawFace = function (element, faceData) {
|
||||
.attr('fill', '#666')
|
||||
.attr('stroke', '#666');
|
||||
|
||||
/** @param {any} face */
|
||||
function smile(face) {
|
||||
const arc = d3arc()
|
||||
.startAngle(Math.PI / 2)
|
||||
@ -65,6 +66,7 @@ export const drawFace = function (element, faceData) {
|
||||
.attr('transform', 'translate(' + faceData.cx + ',' + (faceData.cy + 2) + ')');
|
||||
}
|
||||
|
||||
/** @param {any} face */
|
||||
function sad(face) {
|
||||
const arc = d3arc()
|
||||
.startAngle((3 * Math.PI) / 2)
|
||||
@ -79,6 +81,7 @@ export const drawFace = function (element, faceData) {
|
||||
.attr('transform', 'translate(' + faceData.cx + ',' + (faceData.cy + 7) + ')');
|
||||
}
|
||||
|
||||
/** @param {any} face */
|
||||
function ambivalent(face) {
|
||||
face
|
||||
.append('line')
|
||||
@ -147,6 +150,13 @@ export const drawText = function (elem, textData) {
|
||||
};
|
||||
|
||||
export const drawLabel = function (elem, txtObject) {
|
||||
/**
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} cut
|
||||
*/
|
||||
function genPoints(x, y, width, height, cut) {
|
||||
return (
|
||||
x +
|
||||
@ -209,9 +219,10 @@ export const drawSection = function (elem, section, conf) {
|
||||
let taskCount = -1;
|
||||
/**
|
||||
* Draws an actor in the diagram with the attaced line
|
||||
* @param elem The HTML element
|
||||
* @param task The task to render
|
||||
* @param conf The global configuration
|
||||
*
|
||||
* @param {any} elem The HTML element
|
||||
* @param {any} task The task to render
|
||||
* @param {any} conf The global configuration
|
||||
*/
|
||||
export const drawTask = function (elem, task, conf) {
|
||||
const center = task.x + conf.width / 2;
|
||||
@ -279,8 +290,9 @@ export const drawTask = function (elem, task, conf) {
|
||||
|
||||
/**
|
||||
* Draws a background rectangle
|
||||
* @param elem The html element
|
||||
* @param bounds The bounds of the drawing
|
||||
*
|
||||
* @param {any} elem The html element
|
||||
* @param {any} bounds The bounds of the drawing
|
||||
*/
|
||||
export const drawBackgroundRect = function (elem, bounds) {
|
||||
const rectElem = drawRect(elem, {
|
||||
@ -321,6 +333,16 @@ export const getNoteRect = function () {
|
||||
};
|
||||
|
||||
const _drawTextCandidateFunc = (function () {
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {any} g
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} textAttrs
|
||||
* @param {any} colour
|
||||
*/
|
||||
function byText(content, g, x, y, width, height, textAttrs, colour) {
|
||||
const text = g
|
||||
.append('text')
|
||||
@ -332,6 +354,17 @@ const _drawTextCandidateFunc = (function () {
|
||||
_setTextAttrs(text, textAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {any} g
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} textAttrs
|
||||
* @param {any} conf
|
||||
* @param {any} colour
|
||||
*/
|
||||
function byTspan(content, g, x, y, width, height, textAttrs, conf, colour) {
|
||||
const { taskFontSize, taskFontFamily } = conf;
|
||||
|
||||
@ -361,6 +394,16 @@ const _drawTextCandidateFunc = (function () {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {any} g
|
||||
* @param {any} x
|
||||
* @param {any} y
|
||||
* @param {any} width
|
||||
* @param {any} height
|
||||
* @param {any} textAttrs
|
||||
* @param {any} conf
|
||||
*/
|
||||
function byFo(content, g, x, y, width, height, textAttrs, conf) {
|
||||
const body = g.append('switch');
|
||||
const f = body
|
||||
@ -383,13 +426,16 @@ const _drawTextCandidateFunc = (function () {
|
||||
.style('display', 'table-cell')
|
||||
.style('text-align', 'center')
|
||||
.style('vertical-align', 'middle')
|
||||
// .style('color', colour)
|
||||
.text(content);
|
||||
|
||||
byTspan(content, body, x, y, width, height, textAttrs, conf);
|
||||
_setTextAttrs(text, textAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} toText
|
||||
* @param {any} fromTextAttrsDict
|
||||
*/
|
||||
function _setTextAttrs(toText, fromTextAttrsDict) {
|
||||
for (const key in fromTextAttrsDict) {
|
||||
if (key in fromTextAttrsDict) {
|
||||
|
@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Created by knut on 14-12-11.
|
||||
*/
|
||||
/** Created by knut on 14-12-11. */
|
||||
import { select } from 'd3';
|
||||
import { log } from './logger';
|
||||
|
||||
@ -8,7 +6,8 @@ const conf = {};
|
||||
|
||||
/**
|
||||
* Merges the value of `conf` with the passed `cnf`
|
||||
* @param {Object} cnf Config to merge
|
||||
*
|
||||
* @param {object} cnf Config to merge
|
||||
*/
|
||||
export const setConf = function (cnf) {
|
||||
const keys = Object.keys(cnf);
|
||||
@ -20,8 +19,9 @@ export const setConf = function (cnf) {
|
||||
|
||||
/**
|
||||
* Draws a an info picture in the tag with id: id based on the graph definition in text.
|
||||
* @param id The text for the error
|
||||
* @param ver The version
|
||||
*
|
||||
* @param {string} id The text for the error
|
||||
* @param {string} ver The version
|
||||
*/
|
||||
export const draw = (id, ver) => {
|
||||
try {
|
||||
|
@ -1,12 +1,8 @@
|
||||
import moment from 'moment-mini';
|
||||
|
||||
/**
|
||||
* @typedef {"debug" | "info" | "warn" | "error" | "fatal"} LogLevel A log level
|
||||
*/
|
||||
/** @typedef {'debug' | 'info' | 'warn' | 'error' | 'fatal'} LogLevel A log level */
|
||||
|
||||
/**
|
||||
* @type {Object<LogLevel, number>}
|
||||
*/
|
||||
/** @type {object<LogLevel, number>} */
|
||||
export const LEVELS = {
|
||||
debug: 1,
|
||||
info: 2,
|
||||
@ -25,7 +21,8 @@ export const log = {
|
||||
|
||||
/**
|
||||
* Sets a log level
|
||||
* @param {LogLevel} [level="fatal"] The level to set the logging to
|
||||
*
|
||||
* @param {LogLevel} [level="fatal"] The level to set the logging to. Default is `"fatal"`
|
||||
*/
|
||||
export const setLogLevel = function (level = 'fatal') {
|
||||
if (isNaN(level)) {
|
||||
@ -69,6 +66,7 @@ export const setLogLevel = function (level = 'fatal') {
|
||||
|
||||
/**
|
||||
* Returns a format with the timestamp and the log level
|
||||
*
|
||||
* @param {LogLevel} level The level for the log format
|
||||
* @returns {string} The format with the timestamp and log level
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Web page integration module for the mermaid framework. It uses the mermaidAPI for mermaid functionality and to render
|
||||
* the diagrams to svg code.
|
||||
* Web page integration module for the mermaid framework. It uses the mermaidAPI for mermaid
|
||||
* functionality and to render the diagrams to svg code.
|
||||
*/
|
||||
import { log } from './logger';
|
||||
import mermaidAPI from './mermaidAPI';
|
||||
@ -8,15 +8,17 @@ import utils from './utils';
|
||||
|
||||
/**
|
||||
* ## init
|
||||
*
|
||||
* Function that goes through the document to find the chart definitions in there and render them.
|
||||
*
|
||||
* The function tags the processed attributes with the attribute data-processed and ignores found elements with the
|
||||
* attribute already set. This way the init function can be triggered several times.
|
||||
* The function tags the processed attributes with the attribute data-processed and ignores found
|
||||
* elements with the attribute already set. This way the init function can be triggered several times.
|
||||
*
|
||||
* Optionally, `init` can accept in the second argument one of the following:
|
||||
* - a DOM Node
|
||||
* - an array of DOM nodes (as would come from a jQuery selector)
|
||||
* - a W3C selector, a la `.mermaid`
|
||||
*
|
||||
* - A DOM Node
|
||||
* - An array of DOM nodes (as would come from a jQuery selector)
|
||||
* - A W3C selector, a la `.mermaid`
|
||||
*
|
||||
* ```mermaid
|
||||
* graph LR;
|
||||
@ -24,8 +26,8 @@ import utils from './utils';
|
||||
* b-->|Yes|c(Leave element)
|
||||
* b-->|No |d(Transform)
|
||||
* ```
|
||||
*
|
||||
* Renders the mermaid diagrams
|
||||
* @param nodes a css selector or an array of nodes
|
||||
*/
|
||||
const init = function () {
|
||||
const conf = mermaidAPI.getConfig();
|
||||
@ -145,9 +147,8 @@ const initialize = function (config) {
|
||||
};
|
||||
|
||||
/**
|
||||
* ##contentLoaded
|
||||
* Callback function that is called when page is loaded. This functions fetches configuration for mermaid rendering and
|
||||
* calls init for rendering the mermaid diagrams on the page.
|
||||
* ##contentLoaded Callback function that is called when page is loaded. This functions fetches
|
||||
* configuration for mermaid rendering and calls init for rendering the mermaid diagrams on the page.
|
||||
*/
|
||||
const contentLoaded = function () {
|
||||
let config;
|
||||
|
@ -1,13 +1,15 @@
|
||||
/**
|
||||
*Edit this Page[![N|Solid](img/GitHub-Mark-32px.png)](https://github.com/mermaid-js/mermaid/blob/develop/src/mermaidAPI.js)
|
||||
*
|
||||
*This is the API to be used when optionally handling the integration with the web page, instead of using the default integration provided by mermaid.js.
|
||||
* Edit this
|
||||
* Page[[N|Solid](img/GitHub-Mark-32px.png)](https://github.com/mermaid-js/mermaid/blob/develop/src/mermaidAPI.js)
|
||||
*
|
||||
* This is the API to be used when optionally handling the integration with the web page, instead of
|
||||
* using the default integration provided by mermaid.js.
|
||||
*
|
||||
* The core of this api is the [**render**](Setup.md?id=render) function which, given a graph
|
||||
* definition as text, renders the graph/diagram and returns an svg element for the graph.
|
||||
*
|
||||
* It is is then up to the user of the API to make use of the svg, either insert it somewhere in the page or do something completely different.
|
||||
* It is is then up to the user of the API to make use of the svg, either insert it somewhere in the
|
||||
* page or do something completely different.
|
||||
*
|
||||
* In addition to the render function, a number of behavioral configuration options are available.
|
||||
*
|
||||
@ -55,21 +57,15 @@ import journeyRenderer from './diagrams/user-journey/journeyRenderer';
|
||||
import journeyParser from './diagrams/user-journey/parser/journey';
|
||||
import errorRenderer from './errorRenderer';
|
||||
import { attachFunctions } from './interactionDb';
|
||||
|
||||
// import * as configApi from './config';
|
||||
// // , {
|
||||
// // setConfig,
|
||||
// // configApi.getConfig,
|
||||
// // configApi.updateSiteConfig,
|
||||
// // configApi.setSiteConfig,
|
||||
// // configApi.getSiteConfig,
|
||||
// // configApi.defaultConfig
|
||||
// // }
|
||||
import { log, setLogLevel } from './logger';
|
||||
import getStyles from './styles';
|
||||
import theme from './themes';
|
||||
import utils, { directiveSanitizer, assignWithDepth } from './utils';
|
||||
|
||||
/**
|
||||
* @param text
|
||||
* @returns {any}
|
||||
*/
|
||||
function parse(text) {
|
||||
const cnf = configApi.getConfig();
|
||||
const graphInit = utils.detectInit(text, cnf);
|
||||
@ -203,22 +199,24 @@ export const decodeEntities = function (text) {
|
||||
*
|
||||
* ```javascript
|
||||
* mermaidAPI.initialize({
|
||||
* startOnLoad:true
|
||||
* });
|
||||
* $(function(){
|
||||
* const graphDefinition = 'graph TB\na-->b';
|
||||
* const cb = function(svgGraph){
|
||||
* console.log(svgGraph);
|
||||
* };
|
||||
* mermaidAPI.render('id1',graphDefinition,cb);
|
||||
* });
|
||||
*```
|
||||
* @param id the id of the element to be rendered
|
||||
* @param _txt the graph definition
|
||||
* @param cb callback which is called after rendering is finished with the svg code as inparam.
|
||||
* @param container selector to element in which a div with the graph temporarily will be inserted. In one is
|
||||
* provided a hidden div will be inserted in the body of the page instead. The element will be removed when rendering is
|
||||
* completed.
|
||||
* startOnLoad: true,
|
||||
* });
|
||||
* $(function () {
|
||||
* const graphDefinition = 'graph TB\na-->b';
|
||||
* const cb = function (svgGraph) {
|
||||
* console.log(svgGraph);
|
||||
* };
|
||||
* mermaidAPI.render('id1', graphDefinition, cb);
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param {any} id The id of the element to be rendered
|
||||
* @param {any} _txt The graph definition
|
||||
* @param {any} cb Callback which is called after rendering is finished with the svg code as inparam.
|
||||
* @param {any} container Selector to element in which a div with the graph temporarily will be
|
||||
* inserted. In one is provided a hidden div will be inserted in the body of the page instead. The
|
||||
* element will be removed when rendering is completed.
|
||||
* @returns {any}
|
||||
*/
|
||||
const render = function (id, _txt, cb, container) {
|
||||
configApi.reset();
|
||||
@ -227,13 +225,6 @@ const render = function (id, _txt, cb, container) {
|
||||
if (graphInit) {
|
||||
configApi.addDirective(graphInit);
|
||||
}
|
||||
// else {
|
||||
// configApi.reset();
|
||||
// const siteConfig = configApi.getSiteConfig();
|
||||
// configApi.addDirective(siteConfig);
|
||||
// }
|
||||
// console.warn('Render fetching config');
|
||||
|
||||
let cnf = configApi.getConfig();
|
||||
// Check the maximum allowed text size
|
||||
if (_txt.length > cnf.maxTextSize) {
|
||||
@ -442,17 +433,6 @@ const render = function (id, _txt, cb, container) {
|
||||
.selectAll('foreignobject > *')
|
||||
.attr('xmlns', 'http://www.w3.org/1999/xhtml');
|
||||
|
||||
// if (cnf.arrowMarkerAbsolute) {
|
||||
// url =
|
||||
// window.location.protocol +
|
||||
// '//' +
|
||||
// window.location.host +
|
||||
// window.location.pathname +
|
||||
// window.location.search;
|
||||
// url = url.replace(/\(/g, '\\(');
|
||||
// url = url.replace(/\)/g, '\\)');
|
||||
// }
|
||||
|
||||
// Fix for when the base tag is used
|
||||
let svgCode = select('#d' + id).node().innerHTML;
|
||||
log.debug('cnf.arrowMarkerAbsolute', cnf.arrowMarkerAbsolute);
|
||||
@ -564,6 +544,7 @@ const handleDirective = function (p, directive, type) {
|
||||
}
|
||||
};
|
||||
|
||||
/** @param {any} conf */
|
||||
function updateRendererConfigs(conf) {
|
||||
// Todo remove, all diagrams should get config on demoand from the config object, no need for this
|
||||
gitGraphRenderer.setConf(conf.git);
|
||||
@ -600,6 +581,7 @@ function reinitialize() {
|
||||
// log.debug('mermaidAPI.reinitialize: ', config);
|
||||
}
|
||||
|
||||
/** @param {any} options */
|
||||
function initialize(options) {
|
||||
// console.warn(`mermaidAPI.initialize: v${pkg.version} `, options);
|
||||
|
||||
@ -664,58 +646,58 @@ export default mermaidAPI;
|
||||
* ```html
|
||||
* <script>
|
||||
* var config = {
|
||||
* theme:'default',
|
||||
* logLevel:'fatal',
|
||||
* securityLevel:'strict',
|
||||
* startOnLoad:true,
|
||||
* arrowMarkerAbsolute:false,
|
||||
* theme: 'default',
|
||||
* logLevel: 'fatal',
|
||||
* securityLevel: 'strict',
|
||||
* startOnLoad: true,
|
||||
* arrowMarkerAbsolute: false,
|
||||
*
|
||||
* er:{
|
||||
* diagramPadding:20,
|
||||
* layoutDirection:'TB',
|
||||
* minEntityWidth:100,
|
||||
* minEntityHeight:75,
|
||||
* entityPadding:15,
|
||||
* stroke:'gray',
|
||||
* fill:'honeydew',
|
||||
* fontSize:12,
|
||||
* useMaxWidth:true,
|
||||
* er: {
|
||||
* diagramPadding: 20,
|
||||
* layoutDirection: 'TB',
|
||||
* minEntityWidth: 100,
|
||||
* minEntityHeight: 75,
|
||||
* entityPadding: 15,
|
||||
* stroke: 'gray',
|
||||
* fill: 'honeydew',
|
||||
* fontSize: 12,
|
||||
* useMaxWidth: true,
|
||||
* },
|
||||
* flowchart:{
|
||||
* diagramPadding:8,
|
||||
* htmlLabels:true,
|
||||
* curve:'basis',
|
||||
* flowchart: {
|
||||
* diagramPadding: 8,
|
||||
* htmlLabels: true,
|
||||
* curve: 'basis',
|
||||
* },
|
||||
* sequence:{
|
||||
* diagramMarginX:50,
|
||||
* diagramMarginY:10,
|
||||
* actorMargin:50,
|
||||
* width:150,
|
||||
* height:65,
|
||||
* boxMargin:10,
|
||||
* boxTextMargin:5,
|
||||
* noteMargin:10,
|
||||
* messageMargin:35,
|
||||
* messageAlign:'center',
|
||||
* mirrorActors:true,
|
||||
* bottomMarginAdj:1,
|
||||
* useMaxWidth:true,
|
||||
* rightAngles:false,
|
||||
* showSequenceNumbers:false,
|
||||
* sequence: {
|
||||
* diagramMarginX: 50,
|
||||
* diagramMarginY: 10,
|
||||
* actorMargin: 50,
|
||||
* width: 150,
|
||||
* height: 65,
|
||||
* boxMargin: 10,
|
||||
* boxTextMargin: 5,
|
||||
* noteMargin: 10,
|
||||
* messageMargin: 35,
|
||||
* messageAlign: 'center',
|
||||
* mirrorActors: true,
|
||||
* bottomMarginAdj: 1,
|
||||
* useMaxWidth: true,
|
||||
* rightAngles: false,
|
||||
* showSequenceNumbers: false,
|
||||
* },
|
||||
* gantt: {
|
||||
* titleTopMargin: 25,
|
||||
* barHeight: 20,
|
||||
* barGap: 4,
|
||||
* topPadding: 50,
|
||||
* leftPadding: 75,
|
||||
* gridLineStartPadding: 35,
|
||||
* fontSize: 11,
|
||||
* fontFamily: '"Open-Sans", "sans-serif"',
|
||||
* numberSectionStyles: 4,
|
||||
* axisFormat: '%Y-%m-%d',
|
||||
* topAxis: false,
|
||||
* },
|
||||
* gantt:{
|
||||
* titleTopMargin:25,
|
||||
* barHeight:20,
|
||||
* barGap:4,
|
||||
* topPadding:50,
|
||||
* leftPadding:75,
|
||||
* gridLineStartPadding:35,
|
||||
* fontSize:11,
|
||||
* fontFamily:'"Open-Sans", "sans-serif"',
|
||||
* numberSectionStyles:4,
|
||||
* axisFormat:'%Y-%m-%d',
|
||||
* topAxis:false,
|
||||
* }
|
||||
* };
|
||||
* mermaid.initialize(config);
|
||||
* </script>
|
||||
|
@ -3,7 +3,10 @@ import { mkBorder } from './theme-helpers';
|
||||
class Theme {
|
||||
constructor() {
|
||||
/** # Base variables */
|
||||
/** * background - used to know what the background color is of the diagram. This is used for deducing colors for istance line color. Defaulr value is #f4f4f4. */
|
||||
/**
|
||||
* - Background - used to know what the background color is of the diagram. This is used for
|
||||
* deducing colors for istance line color. Defaulr value is #f4f4f4.
|
||||
*/
|
||||
this.background = '#f4f4f4';
|
||||
this.darkMode = false;
|
||||
|
||||
|
270
src/utils.js
270
src/utils.js
@ -38,34 +38,36 @@ const directiveWithoutOpen =
|
||||
const anyComment = /\s*%%.*\n/gm;
|
||||
|
||||
/**
|
||||
* @function detectInit
|
||||
* Detects the init config object from the text
|
||||
* ```mermaid
|
||||
* %%{init: {"theme": "debug", "logLevel": 1 }}%%
|
||||
* graph LR
|
||||
* a-->b
|
||||
* b-->c
|
||||
* c-->d
|
||||
* d-->e
|
||||
* e-->f
|
||||
* f-->g
|
||||
* g-->h
|
||||
* ```
|
||||
* or
|
||||
* ```mermaid
|
||||
* %%{initialize: {"theme": "dark", logLevel: "debug" }}%%
|
||||
* graph LR
|
||||
* a-->b
|
||||
* b-->c
|
||||
* c-->d
|
||||
* d-->e
|
||||
* e-->f
|
||||
* f-->g
|
||||
* g-->h
|
||||
* @function detectInit Detects the init config object from the text
|
||||
*
|
||||
* ```mermaid
|
||||
* %%{init: {"theme": "debug", "logLevel": 1 }}%%
|
||||
* graph LR
|
||||
* a-->b
|
||||
* b-->c
|
||||
* c-->d
|
||||
* d-->e
|
||||
* e-->f
|
||||
* f-->g
|
||||
* g-->h
|
||||
* ```
|
||||
*
|
||||
* Or
|
||||
*
|
||||
* ```mermaid
|
||||
* %%{initialize: {"theme": "dark", logLevel: "debug" }}%%
|
||||
* graph LR
|
||||
* a-->b
|
||||
* b-->c
|
||||
* c-->d
|
||||
* d-->e
|
||||
* e-->f
|
||||
* f-->g
|
||||
* g-->h
|
||||
* ```
|
||||
* @param {string} text The text defining the graph
|
||||
* @returns {object} the json object representing the init passed to mermaid.initialize()
|
||||
* @param {any} cnf
|
||||
* @returns {object} The json object representing the init passed to mermaid.initialize()
|
||||
*/
|
||||
export const detectInit = function (text, cnf) {
|
||||
let inits = detectDirective(text, /(?:init\b)|(?:initialize\b)/);
|
||||
@ -97,25 +99,25 @@ export const detectInit = function (text, cnf) {
|
||||
};
|
||||
|
||||
/**
|
||||
* @function detectDirective
|
||||
* Detects the directive from the text. Text can be single line or multiline. If type is null or omitted
|
||||
* the first directive encountered in text will be returned
|
||||
* ```mermaid
|
||||
* graph LR
|
||||
* %%{somedirective}%%
|
||||
* a-->b
|
||||
* b-->c
|
||||
* c-->d
|
||||
* d-->e
|
||||
* e-->f
|
||||
* f-->g
|
||||
* g-->h
|
||||
* ```
|
||||
* @function detectDirective Detects the directive from the text. Text can be single line or
|
||||
* multiline. If type is null or omitted the first directive encountered in text will be returned
|
||||
*
|
||||
* ```mermaid
|
||||
* graph LR
|
||||
* %%{somedirective}%%
|
||||
* a-->b
|
||||
* b-->c
|
||||
* c-->d
|
||||
* d-->e
|
||||
* e-->f
|
||||
* f-->g
|
||||
* g-->h
|
||||
* ```
|
||||
* @param {string} text The text defining the graph
|
||||
* @param {string|RegExp} type The directive to return (default: null)
|
||||
* @returns {object | Array} An object or Array representing the directive(s): { type: string, args: object|null } matched by the input type
|
||||
* if a single directive was found, that directive object will be returned.
|
||||
* @param {string | RegExp} type The directive to return (default: null)
|
||||
* @returns {object | Array} An object or Array representing the directive(s): { type: string, args:
|
||||
* object|null } matched by the input type if a single directive was found, that directive object
|
||||
* will be returned.
|
||||
*/
|
||||
export const detectDirective = function (text, type = null) {
|
||||
try {
|
||||
@ -159,23 +161,26 @@ export const detectDirective = function (text, type = null) {
|
||||
};
|
||||
|
||||
/**
|
||||
* @function detectType
|
||||
* Detects the type of the graph text. Takes into consideration the possible existence of an %%init
|
||||
* directive
|
||||
* ```mermaid
|
||||
* %%{initialize: {"startOnLoad": true, logLevel: "fatal" }}%%
|
||||
* graph LR
|
||||
* a-->b
|
||||
* b-->c
|
||||
* c-->d
|
||||
* d-->e
|
||||
* e-->f
|
||||
* f-->g
|
||||
* g-->h
|
||||
* ```
|
||||
* @function detectType Detects the type of the graph text. Takes into consideration the possible
|
||||
* existence of an %%init directive
|
||||
*
|
||||
* ```mermaid
|
||||
* %%{initialize: {"startOnLoad": true, logLevel: "fatal" }}%%
|
||||
* graph LR
|
||||
* a-->b
|
||||
* b-->c
|
||||
* c-->d
|
||||
* d-->e
|
||||
* e-->f
|
||||
* f-->g
|
||||
* g-->h
|
||||
* ```
|
||||
* @param {string} text The text defining the graph
|
||||
* @param {{ class: { defaultRenderer: string } | undefined; state: { defaultRenderer: string } | undefined; flowchart: { defaultRenderer: string } | undefined; }} [cnf]
|
||||
* @param {{
|
||||
* class: { defaultRenderer: string } | undefined;
|
||||
* state: { defaultRenderer: string } | undefined;
|
||||
* flowchart: { defaultRenderer: string } | undefined;
|
||||
* }} [cnf]
|
||||
* @returns {string} A graph definition key
|
||||
*/
|
||||
export const detectType = function (text, cnf) {
|
||||
@ -237,6 +242,7 @@ export const detectType = function (text, cnf) {
|
||||
|
||||
/**
|
||||
* Caches results of functions based on input
|
||||
*
|
||||
* @param {Function} fn Function to run
|
||||
* @param {Function} resolver Function that resolves to an ID given arguments the `fn` takes
|
||||
* @returns {Function} An optimized caching function
|
||||
@ -256,12 +262,11 @@ const memoize = (fn, resolver) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* @function isSubstringInArray
|
||||
* Detects whether a substring in present in a given array
|
||||
* @function isSubstringInArray Detects whether a substring in present in a given array
|
||||
* @param {string} str The substring to detect
|
||||
* @param {array} arr The array to search
|
||||
* @returns {number} the array index containing the substring or -1 if not present
|
||||
**/
|
||||
* @param {Array} arr The array to search
|
||||
* @returns {number} The array index containing the substring or -1 if not present
|
||||
*/
|
||||
export const isSubstringInArray = function (str, arr) {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (arr[i].match(str)) return i;
|
||||
@ -271,8 +276,9 @@ export const isSubstringInArray = function (str, arr) {
|
||||
|
||||
/**
|
||||
* Returns a d3 curve given a curve name
|
||||
*
|
||||
* @param {string | undefined} interpolate The interpolation name
|
||||
* @param {*} defaultCurve The default curve to return
|
||||
* @param {any} defaultCurve The default curve to return
|
||||
* @returns {import('d3-shape').CurveFactory} The curve factory to use
|
||||
*/
|
||||
export const interpolateToCurve = (interpolate, defaultCurve) => {
|
||||
@ -285,8 +291,9 @@ export const interpolateToCurve = (interpolate, defaultCurve) => {
|
||||
|
||||
/**
|
||||
* Formats a URL string
|
||||
*
|
||||
* @param {string} linkStr String of the URL
|
||||
* @param {{ securityLevel: string; }} config Configuration passed to MermaidJS
|
||||
* @param {{ securityLevel: string }} config Configuration passed to MermaidJS
|
||||
* @returns {string | undefined} The formatted URL
|
||||
*/
|
||||
export const formatUrl = (linkStr, config) => {
|
||||
@ -303,8 +310,9 @@ export const formatUrl = (linkStr, config) => {
|
||||
|
||||
/**
|
||||
* Runs a function
|
||||
*
|
||||
* @param {string} functionName A dot seperated path to the function relative to the `window`
|
||||
* @param {...any} params Parameters to pass to the function
|
||||
* @param {...any} params Parameters to pass to the function
|
||||
*/
|
||||
export const runFunc = (functionName, ...params) => {
|
||||
const arrPaths = functionName.split('.');
|
||||
@ -322,13 +330,14 @@ export const runFunc = (functionName, ...params) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {Object} Point A (x, y) point
|
||||
* @typedef {object} Point A (x, y) point
|
||||
* @property {number} x The x value
|
||||
* @property {number} y The y value
|
||||
*/
|
||||
|
||||
/**
|
||||
* Finds the distance between two points using the Distance Formula
|
||||
*
|
||||
* @param {Point} p1 The first point
|
||||
* @param {Point} p2 The second point
|
||||
* @returns {number} The distance
|
||||
@ -337,9 +346,9 @@ const distance = (p1, p2) =>
|
||||
p1 && p2 ? Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2)) : 0;
|
||||
|
||||
/**
|
||||
* @todo Give this a description
|
||||
* @param {Array<Point>} points List of points
|
||||
* @param {Point[]} points List of points
|
||||
* @returns {Point}
|
||||
* @todo Give this a description
|
||||
*/
|
||||
const traverseEdge = (points) => {
|
||||
let prevPoint;
|
||||
@ -380,6 +389,7 @@ const traverseEdge = (points) => {
|
||||
|
||||
/**
|
||||
* Alias for `traverseEdge`
|
||||
*
|
||||
* @param {Point[]} points List of points
|
||||
* @returns {Point} Return result of `transverseEdge`
|
||||
*/
|
||||
@ -438,7 +448,12 @@ const calcCardinalityPosition = (isRelationTypePresent, points, initialPosition)
|
||||
};
|
||||
|
||||
/**
|
||||
* position ['start_left', 'start_right', 'end_left', 'end_right']
|
||||
* Position ['start_left', 'start_right', 'end_left', 'end_right']
|
||||
*
|
||||
* @param {any} terminalMarkerSize
|
||||
* @param {any} position
|
||||
* @param {any} _points
|
||||
* @returns {any}
|
||||
*/
|
||||
const calcTerminalLabelPosition = (terminalMarkerSize, position, _points) => {
|
||||
// Todo looking to faster cloning method
|
||||
@ -510,8 +525,9 @@ const calcTerminalLabelPosition = (terminalMarkerSize, position, _points) => {
|
||||
|
||||
/**
|
||||
* Gets styles from an array of declarations
|
||||
* @param {Array<string>} arr Declarations
|
||||
* @returns {{ style: string; labelStyle: string; }} The styles grouped as strings
|
||||
*
|
||||
* @param {string[]} arr Declarations
|
||||
* @returns {{ style: string; labelStyle: string }} The styles grouped as strings
|
||||
*/
|
||||
export const getStylesFromArray = (arr) => {
|
||||
let style = '';
|
||||
@ -537,6 +553,10 @@ export const generateId = () => {
|
||||
return 'id-' + Math.random().toString(36).substr(2, 12) + '-' + cnt;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} length
|
||||
* @returns {any}
|
||||
*/
|
||||
function makeid(length) {
|
||||
var result = '';
|
||||
var characters = '0123456789abcdef';
|
||||
@ -552,30 +572,39 @@ export const random = (options) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* @function assignWithDepth
|
||||
* Extends the functionality of {@link ObjectConstructor.assign} with the ability to merge arbitrary-depth objects
|
||||
* For each key in src with path `k` (recursively) performs an Object.assign(dst[`k`], src[`k`]) with
|
||||
* a slight change from the typical handling of undefined for dst[`k`]: instead of raising an error,
|
||||
* dst[`k`] is auto-initialized to {} and effectively merged with src[`k`]
|
||||
* <p>
|
||||
* Additionally, dissimilar types will not clobber unless the config.clobber parameter === true. Example:
|
||||
* ```
|
||||
* let config_0 = { foo: { bar: 'bar' }, bar: 'foo' };
|
||||
* let config_1 = { foo: 'foo', bar: 'bar' };
|
||||
* let result = assignWithDepth(config_0, config_1);
|
||||
* console.log(result);
|
||||
* //-> result: { foo: { bar: 'bar' }, bar: 'bar' }
|
||||
* ```
|
||||
* <p>
|
||||
* Traditional Object.assign would have clobbered foo in config_0 with foo in config_1.
|
||||
* <p>
|
||||
* If src is a destructured array of objects and dst is not an array, assignWithDepth will apply each element of src to dst
|
||||
* in order.
|
||||
* @param {any} dst - the destination of the merge
|
||||
* @param {any} src - the source object(s) to merge into destination
|
||||
* @param {{ depth: number, clobber: boolean }} [config={ depth: 2, clobber: false }] - depth: depth to traverse within src and dst for merging -
|
||||
* clobber: should dissimilar types clobber (default: { depth: 2, clobber: false })
|
||||
* @returns {*}
|
||||
* @function assignWithDepth Extends the functionality of {@link ObjectConstructor.assign} with the
|
||||
* ability to merge arbitrary-depth objects For each key in src with path `k` (recursively)
|
||||
* performs an Object.assign(dst[`k`], src[`k`]) with a slight change from the typical handling of
|
||||
* undefined for dst[`k`]: instead of raising an error, dst[`k`] is auto-initialized to {} and
|
||||
* effectively merged with src[`k`]<p> Additionally, dissimilar types will not clobber unless the
|
||||
* config.clobber parameter === true. Example:
|
||||
*
|
||||
* ```js
|
||||
* let config_0 = { foo: { bar: 'bar' }, bar: 'foo' };
|
||||
* let config_1 = { foo: 'foo', bar: 'bar' };
|
||||
* let result = assignWithDepth(config_0, config_1);
|
||||
* console.log(result);
|
||||
* //-> result: { foo: { bar: 'bar' }, bar: 'bar' }
|
||||
* ```
|
||||
*
|
||||
* Traditional Object.assign would have clobbered foo in config_0 with foo in config_1. If src is a
|
||||
* destructured array of objects and dst is not an array, assignWithDepth will apply each element
|
||||
* of src to dst in order.
|
||||
* @param dst
|
||||
* @param src
|
||||
* @param config
|
||||
* @param dst
|
||||
* @param src
|
||||
* @param config
|
||||
* @param dst
|
||||
* @param src
|
||||
* @param config
|
||||
* @param {any} dst - The destination of the merge
|
||||
* @param {any} src - The source object(s) to merge into destination
|
||||
* @param {{ depth: number; clobber: boolean }} [config={ depth: 2, clobber: false }] - Depth: depth
|
||||
* to traverse within src and dst for merging - clobber: should dissimilar types clobber (default:
|
||||
* { depth: 2, clobber: false }). Default is `{ depth: 2, clobber: false }`
|
||||
* @returns {any}
|
||||
*/
|
||||
export const assignWithDepth = function (dst, src, config) {
|
||||
const { depth, clobber } = Object.assign({ depth: 2, clobber: false }, config);
|
||||
@ -633,8 +662,20 @@ export const getTextObj = function () {
|
||||
|
||||
/**
|
||||
* Adds text to an element
|
||||
*
|
||||
* @param {SVGElement} elem Element to add text to
|
||||
* @param {{ text: string; x: number; y: number; anchor: "start" | "middle" | "end"; fontFamily: string; fontSize: string | number; fontWeight: string | number; fill: string; class: string | undefined; textMargin: number; }} textData
|
||||
* @param {{
|
||||
* text: string;
|
||||
* x: number;
|
||||
* y: number;
|
||||
* anchor: 'start' | 'middle' | 'end';
|
||||
* fontFamily: string;
|
||||
* fontSize: string | number;
|
||||
* fontWeight: string | number;
|
||||
* fill: string;
|
||||
* class: string | undefined;
|
||||
* textMargin: number;
|
||||
* }} textData
|
||||
* @returns {SVGTextElement} Text element with given styling and content
|
||||
*/
|
||||
export const drawSimpleText = function (elem, textData) {
|
||||
@ -730,15 +771,14 @@ const breakString = memoize(
|
||||
);
|
||||
|
||||
/**
|
||||
* This calculates the text's height, taking into account the wrap breaks and
|
||||
* both the statically configured height, width, and the length of the text (in pixels).
|
||||
* This calculates the text's height, taking into account the wrap breaks and both the statically
|
||||
* configured height, width, and the length of the text (in pixels).
|
||||
*
|
||||
* If the wrapped text text has greater height, we extend the height, so it's
|
||||
* value won't overflow.
|
||||
* If the wrapped text text has greater height, we extend the height, so it's value won't overflow.
|
||||
*
|
||||
* @return - The height for the given text
|
||||
* @param text the text to measure
|
||||
* @param config - the config for fontSize, fontFamily, and fontWeight all impacting the resulting size
|
||||
* @param {any} text The text to measure
|
||||
* @param {any} config - The config for fontSize, fontFamily, and fontWeight all impacting the resulting size
|
||||
* @returns {any} - The height for the given text
|
||||
*/
|
||||
export const calculateTextHeight = function (text, config) {
|
||||
config = Object.assign(
|
||||
@ -751,9 +791,9 @@ export const calculateTextHeight = function (text, config) {
|
||||
/**
|
||||
* This calculates the width of the given text, font size and family.
|
||||
*
|
||||
* @return - The width for the given text
|
||||
* @param text - The text to calculate the width of
|
||||
* @param config - the config for fontSize, fontFamily, and fontWeight all impacting the resulting size
|
||||
* @param {any} text - The text to calculate the width of
|
||||
* @param {any} config - The config for fontSize, fontFamily, and fontWeight all impacting the resulting size
|
||||
* @returns {any} - The width for the given text
|
||||
*/
|
||||
export const calculateTextWidth = function (text, config) {
|
||||
config = Object.assign({ fontSize: 12, fontWeight: 400, fontFamily: 'Arial' }, config);
|
||||
@ -763,9 +803,10 @@ export const calculateTextWidth = function (text, config) {
|
||||
/**
|
||||
* This calculates the dimensions of the given text, font size, font family, font weight, and margins.
|
||||
*
|
||||
* @return - The width for the given text
|
||||
* @param text - The text to calculate the width of
|
||||
* @param config - the config for fontSize, fontFamily, fontWeight, and margin all impacting the resulting size
|
||||
* @param {any} text - The text to calculate the width of
|
||||
* @param {any} config - The config for fontSize, fontFamily, fontWeight, and margin all impacting
|
||||
* the resulting size
|
||||
* @returns - The width for the given text
|
||||
*/
|
||||
export const calculateTextDimensions = memoize(
|
||||
function (text, config) {
|
||||
@ -829,8 +870,9 @@ export const calculateTextDimensions = memoize(
|
||||
|
||||
/**
|
||||
* Applys d3 attributes
|
||||
* @param {*} d3Elem d3 Element to apply the attributes onto
|
||||
* @param {Array<[string, string]>} attrs Object.keys equivalent format of key to value mapping of attributes
|
||||
*
|
||||
* @param {any} d3Elem D3 Element to apply the attributes onto
|
||||
* @param {[string, string][]} attrs Object.keys equivalent format of key to value mapping of attributes
|
||||
*/
|
||||
const d3Attrs = function (d3Elem, attrs) {
|
||||
for (let attr of attrs) {
|
||||
@ -840,6 +882,7 @@ const d3Attrs = function (d3Elem, attrs) {
|
||||
|
||||
/**
|
||||
* Gives attributes for an SVG's size given arguments
|
||||
*
|
||||
* @param {number} height The height of the SVG
|
||||
* @param {number} width The width of the SVG
|
||||
* @param {boolean} useMaxWidth Whether or not to use max-width and set width to 100%
|
||||
@ -859,6 +902,7 @@ export const calculateSvgSizeAttrs = function (height, width, useMaxWidth) {
|
||||
|
||||
/**
|
||||
* Applies attributes from `calculateSvgSizeAttrs`
|
||||
*
|
||||
* @param {SVGSVGElement} svgElem The SVG Element to configure
|
||||
* @param {number} height The height of the SVG
|
||||
* @param {number} width The width of the SVG
|
||||
@ -888,6 +932,7 @@ let decoder;
|
||||
|
||||
/**
|
||||
* Decodes HTML, source: {@link https://github.com/shrpne/entity-decode/blob/v2.0.1/browser.js}
|
||||
*
|
||||
* @param {string} html HTML as a string
|
||||
* @returns Unescaped HTML
|
||||
*/
|
||||
@ -902,7 +947,8 @@ export const entityDecode = function (html) {
|
||||
|
||||
/**
|
||||
* Sanitizes directive objects
|
||||
* @param {Object} args Directive's JSON
|
||||
*
|
||||
* @param {object} args Directive's JSON
|
||||
*/
|
||||
export const directiveSanitizer = (args) => {
|
||||
log.debug('directiveSanitizer called with', args);
|
||||
|
113
yarn.lock
113
yarn.lock
@ -1272,6 +1272,15 @@
|
||||
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.3.tgz#90420f9f9c6d3987f176a19a7d8e764271a2f55d"
|
||||
integrity sha512-Fxt+AfXgjMoin2maPIYzFZnQjAXjAL0PHscM5pRTtatFqB+vZxAM9tLp2Optnuw3QOQC40jTNeGYFOMvyf7v9g==
|
||||
|
||||
"@es-joy/jsdoccomment@0.12.0":
|
||||
version "0.12.0"
|
||||
resolved "https://registry.yarnpkg.com/@es-joy/jsdoccomment/-/jsdoccomment-0.12.0.tgz#47de05d86e9728ae3a5f1c57d6e9b63b07c6dc98"
|
||||
integrity sha512-Gw4/j9v36IKY8ET+W0GoOzrRw17xjf21EIFFRL3zx21fF5MnqmeNpNi+PU/LKjqLpPb2Pw2XdlJbYM31VVo/PQ==
|
||||
dependencies:
|
||||
comment-parser "1.2.4"
|
||||
esquery "^1.4.0"
|
||||
jsdoc-type-pratt-parser "2.0.0"
|
||||
|
||||
"@eslint/eslintrc@^1.0.4":
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.0.4.tgz#dfe0ff7ba270848d10c5add0715e04964c034b31"
|
||||
@ -1903,6 +1912,13 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.8.tgz#edf1bf1dbf4e04413ca8e5b17b3b7d7d54b59818"
|
||||
integrity sha512-YSBPTLTVm2e2OoQIDYx8HaeWJ5tTToLH67kXR7zYNGupXMEHa2++G8k+DczX2cFVgalypqtyZIcU19AFcmOpmg==
|
||||
|
||||
"@types/mdast@^3.0.0":
|
||||
version "3.0.10"
|
||||
resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-3.0.10.tgz#4724244a82a4598884cbbe9bcfd73dff927ee8af"
|
||||
integrity sha512-W864tg/Osz1+9f4lrGTZpCSO5/z4608eUp19tbozkq2HJK6i3z1kT0H9tlADXuYIb1YYOBByU4Jsqkk75q48qA==
|
||||
dependencies:
|
||||
"@types/unist" "*"
|
||||
|
||||
"@types/minimist@^1.2.0":
|
||||
version "1.2.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.2.tgz#ee771e2ba4b3dc5b372935d549fd9617bf345b8c"
|
||||
@ -1953,6 +1969,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c"
|
||||
integrity sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==
|
||||
|
||||
"@types/unist@*":
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.6.tgz#250a7b16c3b91f672a24552ec64678eeb1d3a08d"
|
||||
integrity sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==
|
||||
|
||||
"@types/unist@^2.0.0", "@types/unist@^2.0.2":
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.5.tgz#fdd299f23205c3455af88ce618dd65c14cb73e22"
|
||||
@ -2614,6 +2635,11 @@ binary-extensions@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
|
||||
integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==
|
||||
|
||||
binary-search-bounds@^2.0.5:
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/binary-search-bounds/-/binary-search-bounds-2.0.5.tgz#125e5bd399882f71e6660d4bf1186384e989fba7"
|
||||
integrity sha512-H0ea4Fd3lS1+sTEB2TgcLoK21lLhwEJzlQv3IN47pJS976Gx4zoWe0ak3q+uYh60ppQxg9F16Ri4tS1sfD4+jA==
|
||||
|
||||
bl@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a"
|
||||
@ -3157,6 +3183,11 @@ commander@^5.1.0:
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-5.1.0.tgz#46abbd1652f8e059bddaef99bbdcb2ad9cf179ae"
|
||||
integrity sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==
|
||||
|
||||
comment-parser@1.2.4, comment-parser@^1.1.4:
|
||||
version "1.2.4"
|
||||
resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-1.2.4.tgz#489f3ee55dfd184a6e4bffb31baba284453cb760"
|
||||
integrity sha512-pm0b+qv+CkWNriSTMsfnjChF9kH0kxz55y44Wo5le9qLxMj5xDQAaEd9ZN1ovSuk9CsrncWaFwgpOMg7ClJwkw==
|
||||
|
||||
common-tags@^1.8.0:
|
||||
version "1.8.0"
|
||||
resolved "https://registry.yarnpkg.com/common-tags/-/common-tags-1.8.0.tgz#8e3153e542d4a39e9b10554434afaaf98956a937"
|
||||
@ -4144,7 +4175,7 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3:
|
||||
dependencies:
|
||||
ms "2.0.0"
|
||||
|
||||
debug@4, debug@4.3.2, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2:
|
||||
debug@4, debug@4.3.2, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2:
|
||||
version "4.3.2"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b"
|
||||
integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==
|
||||
@ -4652,6 +4683,21 @@ eslint-config-prettier@^8.3.0:
|
||||
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz#f7471b20b6fe8a9a9254cc684454202886a2dd7a"
|
||||
integrity sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew==
|
||||
|
||||
eslint-plugin-jsdoc@^37.0.3:
|
||||
version "37.0.3"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-37.0.3.tgz#42ddd0393c166c2724a7fdee808b94ab1d9dfb00"
|
||||
integrity sha512-Qg/gIZAfcrM4Qu/JzcnxPGD45Je6wPLFzMZQboeqit/CL4aY6wuzBTkgUMiWXfw/PaPl+sb0GF1XdBlV23ReDA==
|
||||
dependencies:
|
||||
"@es-joy/jsdoccomment" "0.12.0"
|
||||
comment-parser "1.2.4"
|
||||
debug "^4.3.2"
|
||||
esquery "^1.4.0"
|
||||
jsdoc-type-pratt-parser "^2.0.0"
|
||||
lodash "^4.17.21"
|
||||
regextras "^0.8.0"
|
||||
semver "^7.3.5"
|
||||
spdx-expression-parse "^3.0.1"
|
||||
|
||||
eslint-plugin-prettier@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz#8b99d1e4b8b24a762472b4567992023619cb98e0"
|
||||
@ -6874,6 +6920,11 @@ jsbn@~0.1.0:
|
||||
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
|
||||
integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM=
|
||||
|
||||
jsdoc-type-pratt-parser@2.0.0, jsdoc-type-pratt-parser@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-2.0.0.tgz#ec739a0868922515fcb179852e990e89b52b9044"
|
||||
integrity sha512-sUuj2j48wxrEpbFjDp1sAesAxPiLT+z0SWVmMafyIINs6Lj5gIPKh3VrkBZu4E/Dv+wHpOot0m6H8zlHQjwqeQ==
|
||||
|
||||
jsdom@^16.6.0:
|
||||
version "16.6.0"
|
||||
resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.6.0.tgz#f79b3786682065492a3da6a60a4695da983805ac"
|
||||
@ -7107,6 +7158,11 @@ lines-and-columns@^1.1.6:
|
||||
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
|
||||
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=
|
||||
|
||||
linguist-languages@^7.13.0:
|
||||
version "7.15.0"
|
||||
resolved "https://registry.yarnpkg.com/linguist-languages/-/linguist-languages-7.15.0.tgz#a93bed6b93015d8133622cb05da6296890862bfa"
|
||||
integrity sha512-qkSSNDjDDycZ2Wcw+GziNBB3nNo3ddYUInM/PL8Amgwbd9RQ/BKGj2/1d6mdxKgBFnUqZuaDbkIwkE4KUwwmtQ==
|
||||
|
||||
listr2@^3.8.3:
|
||||
version "3.10.0"
|
||||
resolved "https://registry.yarnpkg.com/listr2/-/listr2-3.10.0.tgz#58105a53ed7fa1430d1b738c6055ef7bb006160f"
|
||||
@ -7342,6 +7398,17 @@ mdast-util-definitions@^1.2.0:
|
||||
dependencies:
|
||||
unist-util-visit "^1.0.0"
|
||||
|
||||
mdast-util-from-markdown@^0.8.5:
|
||||
version "0.8.5"
|
||||
resolved "https://registry.yarnpkg.com/mdast-util-from-markdown/-/mdast-util-from-markdown-0.8.5.tgz#d1ef2ca42bc377ecb0463a987910dae89bd9a28c"
|
||||
integrity sha512-2hkTXtYYnr+NubD/g6KGBS/0mFmBcifAsI0yIWRiRo0PjVs6SSOSOdtzbp6kSGnShDN6G5aWZpKQ2lWRy27mWQ==
|
||||
dependencies:
|
||||
"@types/mdast" "^3.0.0"
|
||||
mdast-util-to-string "^2.0.0"
|
||||
micromark "~2.11.0"
|
||||
parse-entities "^2.0.0"
|
||||
unist-util-stringify-position "^2.0.0"
|
||||
|
||||
mdast-util-inject@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/mdast-util-inject/-/mdast-util-inject-1.1.0.tgz#db06b8b585be959a2dcd2f87f472ba9b756f3675"
|
||||
@ -7371,6 +7438,11 @@ mdast-util-to-string@^1.0.0, mdast-util-to-string@^1.0.5:
|
||||
resolved "https://registry.yarnpkg.com/mdast-util-to-string/-/mdast-util-to-string-1.1.0.tgz#27055500103f51637bd07d01da01eb1967a43527"
|
||||
integrity sha512-jVU0Nr2B9X3MU4tSK7JP1CMkSvOj7X5l/GboG1tKRw52lLF1x2Ju92Ms9tNetCcbfX3hzlM73zYo2NKkWSfF/A==
|
||||
|
||||
mdast-util-to-string@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/mdast-util-to-string/-/mdast-util-to-string-2.0.0.tgz#b8cfe6a713e1091cb5b728fc48885a4767f8b97b"
|
||||
integrity sha512-AW4DRS3QbBayY/jJmD8437V1Gombjf8RSOUCMFBuo5iHi58AGEgVCKQ+ezHkZZDpAQS75hcBMpLqjpJTjtUL7w==
|
||||
|
||||
mdast-util-toc@^3.0.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/mdast-util-toc/-/mdast-util-toc-3.1.0.tgz#395eeb877f067f9d2165d990d77c7eea6f740934"
|
||||
@ -7452,6 +7524,14 @@ methods@~1.1.2:
|
||||
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"
|
||||
integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=
|
||||
|
||||
micromark@~2.11.0:
|
||||
version "2.11.4"
|
||||
resolved "https://registry.yarnpkg.com/micromark/-/micromark-2.11.4.tgz#d13436138eea826383e822449c9a5c50ee44665a"
|
||||
integrity sha512-+WoovN/ppKolQOFIAajxi7Lu9kInbPxFuTBVEavFcL8eAfVstoc5MocPmqBeAdBOJV00uaVjegzH4+MA0DN/uA==
|
||||
dependencies:
|
||||
debug "^4.0.0"
|
||||
parse-entities "^2.0.0"
|
||||
|
||||
micromatch@^3.1.5:
|
||||
version "3.1.10"
|
||||
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23"
|
||||
@ -8042,6 +8122,18 @@ parse-entities@^1.0.2, parse-entities@^1.1.0:
|
||||
is-decimal "^1.0.0"
|
||||
is-hexadecimal "^1.0.0"
|
||||
|
||||
parse-entities@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/parse-entities/-/parse-entities-2.0.0.tgz#53c6eb5b9314a1f4ec99fa0fdf7ce01ecda0cbe8"
|
||||
integrity sha512-kkywGpCcRYhqQIchaWqZ875wzpS/bMKhz5HnN3p7wveJTkTtyAB/AlnS0f8DFSqYW1T82t6yEAkEcB+A1I3MbQ==
|
||||
dependencies:
|
||||
character-entities "^1.0.0"
|
||||
character-entities-legacy "^1.0.0"
|
||||
character-reference-invalid "^1.0.0"
|
||||
is-alphanumerical "^1.0.0"
|
||||
is-decimal "^1.0.0"
|
||||
is-hexadecimal "^1.0.0"
|
||||
|
||||
parse-filepath@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/parse-filepath/-/parse-filepath-1.0.2.tgz#a632127f53aaf3d15876f5872f3ffac763d6c891"
|
||||
@ -8282,6 +8374,16 @@ prettier-linter-helpers@^1.0.0:
|
||||
dependencies:
|
||||
fast-diff "^1.1.2"
|
||||
|
||||
prettier-plugin-jsdoc@^0.3.30:
|
||||
version "0.3.30"
|
||||
resolved "https://registry.yarnpkg.com/prettier-plugin-jsdoc/-/prettier-plugin-jsdoc-0.3.30.tgz#c0cce02279ad1467c9dc9660c6dec1fada259d7f"
|
||||
integrity sha512-BTBojOMmrUA1qsWLpJN5whUfU/E72WBUQAB5AvrDkha+O8TxmqaAivnuW+87ItYGRPBFWWzj2r5iWELhBml1Ag==
|
||||
dependencies:
|
||||
binary-search-bounds "^2.0.5"
|
||||
comment-parser "^1.1.4"
|
||||
linguist-languages "^7.13.0"
|
||||
mdast-util-from-markdown "^0.8.5"
|
||||
|
||||
prettier@^2.3.2:
|
||||
version "2.4.1"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.4.1.tgz#671e11c89c14a4cfc876ce564106c4a6726c9f5c"
|
||||
@ -8671,6 +8773,11 @@ regexpu-core@^4.7.1:
|
||||
unicode-match-property-ecmascript "^1.0.4"
|
||||
unicode-match-property-value-ecmascript "^1.2.0"
|
||||
|
||||
regextras@^0.8.0:
|
||||
version "0.8.0"
|
||||
resolved "https://registry.yarnpkg.com/regextras/-/regextras-0.8.0.tgz#ec0f99853d4912839321172f608b544814b02217"
|
||||
integrity sha512-k519uI04Z3SaY0fLX843MRXnDeG2+vHOFsyhiPZvNLe7r8rD2YNRjq4BQLZZ0oAr2NrtvZlICsXysGNFPGa3CQ==
|
||||
|
||||
regjsgen@^0.5.1:
|
||||
version "0.5.2"
|
||||
resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.5.2.tgz#92ff295fb1deecbf6ecdab2543d207e91aa33733"
|
||||
@ -9054,7 +9161,7 @@ semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0:
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
||||
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
||||
|
||||
semver@^7.1.1, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4:
|
||||
semver@^7.1.1, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5:
|
||||
version "7.3.5"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
|
||||
integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
|
||||
@ -9318,7 +9425,7 @@ spdx-exceptions@^2.1.0:
|
||||
resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d"
|
||||
integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==
|
||||
|
||||
spdx-expression-parse@^3.0.0:
|
||||
spdx-expression-parse@^3.0.0, spdx-expression-parse@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679"
|
||||
integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==
|
||||
|
Loading…
x
Reference in New Issue
Block a user