mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-26 10:49:38 +02:00
chore: Fix eslint errors
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
BRANDES
|
||||
KOEPF
|
||||
circo
|
||||
handdrawn
|
||||
KOEPF
|
||||
neato
|
||||
newbranch
|
||||
|
@@ -97,14 +97,14 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
|
||||
// Also figure out which edges point to/from clusters and adjust them accordingly
|
||||
// Edges from/to clusters really points to the first child in the cluster.
|
||||
// TODO: pick optimal child in the cluster to us as link anchor
|
||||
graph.edges().forEach(function (e) {
|
||||
graph.edges().forEach(async function (e) {
|
||||
const edge = graph.edge(e.v, e.w, e.name);
|
||||
log.info('Edge ' + e.v + ' -> ' + e.w + ': ' + JSON.stringify(e));
|
||||
log.info('Edge ' + e.v + ' -> ' + e.w + ': ', e, ' ', JSON.stringify(graph.edge(e)));
|
||||
|
||||
// Check if link is either from or to a cluster
|
||||
log.info('Fix', clusterDb, 'ids:', e.v, e.w, 'Translating: ', clusterDb[e.v], clusterDb[e.w]);
|
||||
insertEdgeLabel(edgeLabels, edge);
|
||||
await insertEdgeLabel(edgeLabels, edge);
|
||||
});
|
||||
|
||||
graph.edges().forEach(function (e) {
|
||||
|
@@ -16,18 +16,20 @@ import defaultConfig from '../../defaultConfig.js';
|
||||
// Inject the layout algorithm into cytoscape
|
||||
cytoscape.use(coseBilkent);
|
||||
|
||||
function drawNodes(
|
||||
async function drawNodes(
|
||||
db: MindmapDB,
|
||||
svg: D3Element,
|
||||
mindmap: FilledMindMapNode,
|
||||
section: number,
|
||||
conf: MermaidConfig
|
||||
) {
|
||||
drawNode(db, svg, mindmap, section, conf);
|
||||
await drawNode(db, svg, mindmap, section, conf);
|
||||
if (mindmap.children) {
|
||||
mindmap.children.forEach((child, index) => {
|
||||
drawNodes(db, svg, child, section < 0 ? index : section, conf);
|
||||
});
|
||||
await Promise.all(
|
||||
mindmap.children.map((child, index) =>
|
||||
drawNodes(db, svg, child, section < 0 ? index : section, conf)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +179,7 @@ export const draw: DrawDefinition = async (text, id, _version, diagObj) => {
|
||||
edgesElem.attr('class', 'mindmap-edges');
|
||||
const nodesElem = svg.append('g');
|
||||
nodesElem.attr('class', 'mindmap-nodes');
|
||||
drawNodes(db, nodesElem, mm as FilledMindMapNode, -1, conf);
|
||||
await drawNodes(db, nodesElem, mm as FilledMindMapNode, -1, conf);
|
||||
|
||||
// Next step is to layout the mindmap, giving each node a position
|
||||
|
||||
|
@@ -174,13 +174,13 @@ const roundedRectBkg: ShapeFunction = function (db, elem, node) {
|
||||
* @param conf - The configuration object
|
||||
* @returns The height nodes dom element
|
||||
*/
|
||||
export const drawNode = function (
|
||||
export const drawNode = async function (
|
||||
db: MindmapDB,
|
||||
elem: D3Element,
|
||||
node: FilledMindMapNode,
|
||||
fullSection: number,
|
||||
conf: MermaidConfig
|
||||
): number {
|
||||
): Promise<number> {
|
||||
const htmlLabels = conf.htmlLabels;
|
||||
const section = fullSection % (MAX_SECTIONS - 1);
|
||||
const nodeElem = elem.append('g');
|
||||
@@ -195,7 +195,7 @@ export const drawNode = function (
|
||||
// Create the wrapped text element
|
||||
const textElem = nodeElem.append('g');
|
||||
const description = node.descr.replace(/(<br\/*>)/g, '\n');
|
||||
createText(
|
||||
await createText(
|
||||
textElem,
|
||||
description,
|
||||
{
|
||||
|
@@ -123,8 +123,7 @@ const setupDoc = (parentParsedItem, doc, diagramStates, nodes, edges, altFlag, l
|
||||
const getDir = (parsedItem, defaultDir = DEFAULT_NESTED_DOC_DIR) => {
|
||||
let dir = defaultDir;
|
||||
if (parsedItem.doc) {
|
||||
for (let i = 0; i < parsedItem.doc.length; i++) {
|
||||
const parsedItemDoc = parsedItem.doc[i];
|
||||
for (const parsedItemDoc of parsedItem.doc) {
|
||||
if (parsedItemDoc.stmt === 'dir') {
|
||||
dir = parsedItemDoc.value;
|
||||
}
|
||||
@@ -133,21 +132,6 @@ const getDir = (parsedItem, defaultDir = DEFAULT_NESTED_DOC_DIR) => {
|
||||
return dir;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a new list of classes.
|
||||
* In the future, this can be replaced with a class common to all diagrams.
|
||||
* ClassDef information = { id: id, styles: [], textStyles: [] }
|
||||
*
|
||||
* @returns {{}}
|
||||
*/
|
||||
function newClassesList() {
|
||||
return {};
|
||||
}
|
||||
|
||||
// let direction = DEFAULT_DIAGRAM_DIRECTION;
|
||||
// let rootDoc = [];
|
||||
let cssClasses = newClassesList(); // style classes defined by a classDef
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nodes
|
||||
|
@@ -19,8 +19,7 @@ import { CSS_DIAGRAM, DEFAULT_NESTED_DOC_DIR } from './stateCommon.js';
|
||||
const getDir = (parsedItem: any, defaultDir = DEFAULT_NESTED_DOC_DIR) => {
|
||||
let dir = defaultDir;
|
||||
if (parsedItem.doc) {
|
||||
for (let i = 0; i < parsedItem.doc.length; i++) {
|
||||
const parsedItemDoc = parsedItem.doc[i];
|
||||
for (const parsedItemDoc of parsedItem.doc) {
|
||||
if (parsedItemDoc.stmt === 'dir') {
|
||||
dir = parsedItemDoc.value;
|
||||
}
|
||||
|
@@ -15,9 +15,6 @@ export const LEVELS: Record<LogLevel, number> = {
|
||||
fatal: 5,
|
||||
};
|
||||
|
||||
console.log('apa');
|
||||
const apa = 1;
|
||||
|
||||
export const log: Record<keyof typeof LEVELS, typeof console.log> = {
|
||||
trace: (..._args: any[]) => {},
|
||||
debug: (..._args: any[]) => {},
|
||||
|
@@ -231,7 +231,9 @@ export const createText = async (
|
||||
structuredText,
|
||||
text ? addSvgBackground : false
|
||||
);
|
||||
if (/stroke:/.exec(style)) {style = style.replace('stroke:', 'lineColor:');}
|
||||
if (/stroke:/.exec(style)) {
|
||||
style = style.replace('stroke:', 'lineColor:');
|
||||
}
|
||||
select(svgLabel)
|
||||
.select('text')
|
||||
.attr('style', style.replace(/color:/g, 'fill:'));
|
||||
|
@@ -165,7 +165,7 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
|
||||
log.info('Edge ' + e.v + ' -> ' + e.w + ': ' + JSON.stringify(e));
|
||||
});
|
||||
|
||||
graph.nodes().map(async function (v) {
|
||||
graph.nodes().map(function (v) {
|
||||
const node = graph.node(v);
|
||||
log.info(
|
||||
'Position PRE XBX => ' + v + ': (' + node.x,
|
||||
@@ -186,7 +186,7 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
|
||||
dagreLayout(graph);
|
||||
log.info('Graph after layout:', JSON.stringify(graphlibJson.write(graph)));
|
||||
|
||||
graph.nodes().map(async function (v) {
|
||||
graph.nodes().map(function (v) {
|
||||
const node = graph.node(v);
|
||||
log.info(
|
||||
'Position AFTER XBX => ' + v + ': (' + node.x,
|
||||
@@ -202,13 +202,9 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
|
||||
// Move the nodes to the correct place
|
||||
let diff = 0;
|
||||
let { subGraphTitleTotalMargin } = getSubGraphTitleMargins(siteConfig);
|
||||
// subGraphTitleTotalMargin = 0;
|
||||
await Promise.all(
|
||||
sortNodesByHierarchy(graph).map(async function (v) {
|
||||
const node = graph.node(v);
|
||||
const p = graph.node(node?.parentId);
|
||||
// subGraphTitleTotalMargin = p?.offsetY || subGraphTitleTotalMargin;
|
||||
|
||||
log.info(
|
||||
'Position XBX => ' + v + ': (' + node.x,
|
||||
',' + node.y,
|
||||
@@ -218,11 +214,8 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
|
||||
node.height
|
||||
);
|
||||
if (node?.clusterNode) {
|
||||
const parentId = graph.parent(v);
|
||||
// Adjust for padding when on root level
|
||||
node.y += subGraphTitleTotalMargin;
|
||||
// node.y = parentId ? node.y - 8 : node.y - 8;
|
||||
// node.x -= 8;
|
||||
|
||||
log.info(
|
||||
'A tainted cluster node XBX1',
|
||||
@@ -235,9 +228,6 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
|
||||
graph.parent(v)
|
||||
);
|
||||
clusterDb[node.id].node = node;
|
||||
// node.y += subGraphTitleTotalMargin - 10;
|
||||
// node.y -= (node.offsetY || 0) / 2;
|
||||
// node.y -= 10;
|
||||
positionNode(node);
|
||||
} else {
|
||||
// A tainted cluster node
|
||||
@@ -258,8 +248,6 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
|
||||
const labelHeight = node?.labelBBox?.height || 0;
|
||||
const offsetY = labelHeight - halfPadding || 0;
|
||||
log.debug('OffsetY', offsetY, 'labelHeight', labelHeight, 'halfPadding', halfPadding);
|
||||
// node.y += offsetY + (parent?.offsetY / 2 || 0);
|
||||
// node.offsetY = offsetY;
|
||||
await insertCluster(clusters, node);
|
||||
|
||||
// A cluster in the non-recursive way
|
||||
|
@@ -16,7 +16,7 @@ function applyStyle(dom, styleFn) {
|
||||
|
||||
/**
|
||||
* @param {any} node
|
||||
* @returns {SVGForeignObjectElement} Node
|
||||
* @returns {Promise<SVGForeignObjectElement>} Node
|
||||
*/
|
||||
async function addHtmlLabel(node) {
|
||||
const fo = select(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'));
|
||||
|
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
import type { SVG } from '$root/diagram-api/types.js';
|
||||
import type { Mocked } from 'vitest';
|
||||
import { addEdgeMarkers } from './edgeMarker.js';
|
||||
|
@@ -425,9 +425,8 @@ const findAdjacentPoint = function (pointA, pointB, distance) {
|
||||
*/
|
||||
|
||||
const fixCorners = function (lineData) {
|
||||
const { cornerPoints, cornerPointPositions } = extractCornerPoints(lineData);
|
||||
const { cornerPointPositions } = extractCornerPoints(lineData);
|
||||
const newLineData = [];
|
||||
let lastCorner = 0;
|
||||
for (let i = 0; i < lineData.length; i++) {
|
||||
if (cornerPointPositions.includes(i)) {
|
||||
const prevPoint = lineData[i - 1];
|
||||
|
@@ -6,9 +6,9 @@ import {
|
||||
userNodeOverrides,
|
||||
styles2String,
|
||||
} from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
||||
// @ts-expect-error TODO: Fix rough typings
|
||||
import rough from 'roughjs';
|
||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
||||
import { log } from '$root/logger.js';
|
||||
|
||||
export const drawRect = async (parent: SVGAElement, node: Node, options: RectOptions) => {
|
||||
const { look } = getConfig();
|
||||
@@ -30,7 +30,7 @@ export const drawRect = async (parent: SVGAElement, node: Node, options: RectOpt
|
||||
const { cssStyles } = node;
|
||||
|
||||
//use options rx, ry overrides if present
|
||||
if (options && options.rx && options.ry) {
|
||||
if (options?.rx && options.ry) {
|
||||
rx = options.rx;
|
||||
ry = options.ry;
|
||||
}
|
||||
|
Reference in New Issue
Block a user