mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-01 11:24:16 +01:00
#5237 Lint fixes
This commit is contained in:
@@ -42,9 +42,6 @@ export const getArrowPoints = (
|
||||
// Padding to use, half of the node padding.
|
||||
const padding = node.padding / 2;
|
||||
|
||||
// Initialize an empty array to store points for the arrow.
|
||||
const points = [];
|
||||
|
||||
if (
|
||||
directions.has('right') &&
|
||||
directions.has('left') &&
|
||||
|
||||
@@ -110,12 +110,13 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
|
||||
graph.edges().forEach(function (e) {
|
||||
log.info('Edge ' + e.v + ' -> ' + e.w + ': ' + JSON.stringify(e));
|
||||
});
|
||||
log.info('Graph before layout:', JSON.stringify(graphlibJson.write(graph)));
|
||||
log.info('#############################################');
|
||||
log.info('### Layout ###');
|
||||
log.info('#############################################');
|
||||
log.info(graph);
|
||||
dagreLayout(graph);
|
||||
log.info('Graph after layout:', graphlibJson.write(graph));
|
||||
log.info('Graph after layout:', JSON.stringify(graphlibJson.write(graph)));
|
||||
// Move the nodes to the correct place
|
||||
let diff = 0;
|
||||
const { subGraphTitleTotalMargin } = getSubGraphTitleMargins(siteConfig);
|
||||
|
||||
@@ -85,7 +85,7 @@ export const draw = async function (
|
||||
}
|
||||
|
||||
// Get color scheme for the graph
|
||||
const colorScheme = d3scaleOrdinal(d3schemeTableau10);
|
||||
// const colorScheme = d3scaleOrdinal(d3schemeTableau10);
|
||||
};
|
||||
|
||||
export default {
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { DiagramDefinition } from '../../diagram-api/types.js';
|
||||
import parser from './parser/stateDiagram.jison';
|
||||
import db from './stateDb.js';
|
||||
import styles from './styles.js';
|
||||
//import renderer from './stateRenderer-v2.js';
|
||||
// import renderer from './stateRenderer-v2.js';
|
||||
import renderer from './stateRenderer-v3-unified.js';
|
||||
|
||||
export const diagram: DiagramDefinition = {
|
||||
|
||||
@@ -6,12 +6,7 @@ import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shape
|
||||
import rough from 'roughjs';
|
||||
|
||||
export const circle = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
||||
parent,
|
||||
node,
|
||||
getNodeClasses(node),
|
||||
true
|
||||
);
|
||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
|
||||
const radius = bbox.width / 2 + halfPadding;
|
||||
let circleElem;
|
||||
|
||||
@@ -50,7 +50,7 @@ export const createInnerCylinderPathD = (
|
||||
return [`M${x - width / 2},${-height / 2}`, `a${rx},${ry} 0,0,0 ${width},0`].join(' ');
|
||||
};
|
||||
export const cylinder = async (parent: SVGAElement, node: Node) => {
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
|
||||
const w = bbox.width + node.padding;
|
||||
const rx = w / 2;
|
||||
|
||||
@@ -7,12 +7,7 @@ import rough from 'roughjs';
|
||||
//import d3 from 'd3';
|
||||
|
||||
export const doublecircle = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
||||
parent,
|
||||
node,
|
||||
getNodeClasses(node),
|
||||
true
|
||||
);
|
||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
const gap = 5;
|
||||
const outerRadius = bbox.width / 2 + halfPadding + gap;
|
||||
const innerRadius = bbox.width / 2 + halfPadding;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { log } from '$root/logger.js';
|
||||
import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js';
|
||||
import intersect from '../intersect/index.js';
|
||||
import type { Node, RectOptions } from '$root/rendering-util/types.d.ts';
|
||||
@@ -8,15 +7,9 @@ import rough from 'roughjs';
|
||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
||||
|
||||
export const drawRect = async (parent: SVGAElement, node: Node, options: RectOptions) => {
|
||||
const { themeVariables, handdrawnSeed, look } = getConfig();
|
||||
const { nodeBorder, mainBkg } = themeVariables;
|
||||
const { themeVariables, look } = getConfig();
|
||||
|
||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
||||
parent,
|
||||
node,
|
||||
getNodeClasses(node),
|
||||
true
|
||||
);
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
|
||||
const totalWidth = Math.max(bbox.width + options.labelPaddingX * 2, node?.width || 0);
|
||||
const totalHeight = Math.max(bbox.height + options.labelPaddingY * 2, node?.height || 0);
|
||||
@@ -72,7 +65,7 @@ export const drawRect = async (parent: SVGAElement, node: Node, options: RectOpt
|
||||
};
|
||||
|
||||
export const labelRect = async (parent: SVGElement, node: Node) => {
|
||||
const { shapeSvg } = await labelHelper(parent, node, 'label', true);
|
||||
const { shapeSvg } = await labelHelper(parent, node, 'label');
|
||||
|
||||
// log.trace('Classes = ', node.class);
|
||||
// add the rect
|
||||
|
||||
@@ -26,12 +26,7 @@ export const createHexagonPathD = (
|
||||
};
|
||||
|
||||
export const hexagon = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
||||
parent,
|
||||
node,
|
||||
getNodeClasses(node),
|
||||
true
|
||||
);
|
||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
|
||||
const f = 4;
|
||||
const h = bbox.height + node.padding;
|
||||
|
||||
@@ -23,7 +23,7 @@ export const createInvertedTrapezoidPathD = (
|
||||
};
|
||||
|
||||
export const inv_trapezoid = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
|
||||
const w = bbox.width + node.padding;
|
||||
const h = bbox.height + node.padding;
|
||||
|
||||
@@ -22,7 +22,7 @@ export const createLeanLeftPathD = (
|
||||
};
|
||||
|
||||
export const lean_left = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
|
||||
const w = bbox.width + node.padding;
|
||||
const h = bbox.height + node.padding;
|
||||
|
||||
@@ -22,7 +22,7 @@ export const createLeanRightPathD = (
|
||||
};
|
||||
|
||||
export const lean_right = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
|
||||
const w = bbox.width + node.padding;
|
||||
const h = bbox.height + node.padding;
|
||||
|
||||
@@ -16,8 +16,7 @@ export const note = async (parent: SVGAElement, node: Node) => {
|
||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
||||
parent,
|
||||
node,
|
||||
'node ' + node.cssClasses,
|
||||
true
|
||||
'node ' + node.cssClasses
|
||||
);
|
||||
|
||||
log.info('Classes = ', node.cssClasses);
|
||||
|
||||
@@ -17,7 +17,7 @@ export const createDecisionBoxPathD = (x: number, y: number, size: number): stri
|
||||
};
|
||||
|
||||
export const question = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
|
||||
const w = bbox.width + node.padding;
|
||||
const h = bbox.height + node.padding;
|
||||
|
||||
@@ -21,7 +21,7 @@ export const rect_left_inv_arrow = async (
|
||||
parent: SVGAElement,
|
||||
node: Node
|
||||
): Promise<SVGAElement> => {
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
|
||||
const w = bbox.width + node.padding;
|
||||
const h = bbox.height + node.padding;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Node, RectOptions } from '$root/rendering-util/types.d.ts';
|
||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||
import { select } from 'd3';
|
||||
import { evaluate } from '$root/diagrams/common/common.js';
|
||||
import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js';
|
||||
import { updateNodeBounds } from './util.js';
|
||||
import createLabel from '../createLabel.js';
|
||||
import intersect from '../intersect/index.js';
|
||||
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { log } from '$root/logger.js';
|
||||
import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js';
|
||||
import intersect from '../intersect/index.js';
|
||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||
@@ -52,7 +51,7 @@ export const createStadiumPathD = (
|
||||
};
|
||||
|
||||
export const stadium = async (parent: SVGAElement, node: Node) => {
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
|
||||
const h = bbox.height + node.padding;
|
||||
const w = bbox.width + h / 4 + node.padding;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { log } from '$root/logger.js';
|
||||
import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js';
|
||||
import intersect from '../intersect/index.js';
|
||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||
@@ -33,7 +32,7 @@ export const createSubroutinePathD = (
|
||||
};
|
||||
|
||||
export const subroutine = async (parent: SVGAElement, node: Node) => {
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
const halfPadding = (node?.padding || 0) / 2;
|
||||
const w = bbox.width + node.padding;
|
||||
const h = bbox.height + node.padding;
|
||||
@@ -58,7 +57,6 @@ export const subroutine = async (parent: SVGAElement, node: Node) => {
|
||||
// @ts-ignore - rough is not typed
|
||||
const rc = rough.svg(shapeSvg);
|
||||
const options = userNodeOverrides(node, {});
|
||||
const pathData = createSubroutinePathD(-w / 2, -h / 2, w, h);
|
||||
|
||||
const roughNode = rc.rectangle(x - 8, y, w + 16, h, options);
|
||||
const l1 = rc.line(x, y, x, y + h, options);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { log } from '$root/logger.js';
|
||||
import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js';
|
||||
import intersect from '../intersect/index.js';
|
||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||
@@ -22,7 +21,7 @@ export const createTrapezoidPathD = (
|
||||
};
|
||||
|
||||
export const trapezoid = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
||||
|
||||
const w = bbox.width + node.padding;
|
||||
const h = bbox.height + node.padding;
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import createLabel from '../createLabel.js';
|
||||
import { createText } from '$root/rendering-util/createText.ts';
|
||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
||||
import { select } from 'd3';
|
||||
import { evaluate, sanitizeText } from '$root/diagrams/common/common.js';
|
||||
import { decodeEntities } from '$root/utils.js';
|
||||
|
||||
export const labelHelper = async (parent, node, _classes, isNode) => {
|
||||
export const labelHelper = async (parent, node, _classes) => {
|
||||
let cssClasses;
|
||||
const useHtmlLabels = node.useHtmlLabels || evaluate(getConfig().flowchart.htmlLabels);
|
||||
if (!_classes) {
|
||||
|
||||
Reference in New Issue
Block a user