mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-18 03:34:12 +01:00
MC-1730 Lint fixes
This commit is contained in:
@@ -1,21 +1,5 @@
|
|||||||
import { layout as dagreLayout } from 'dagre-d3-es/src/dagre/index.js';
|
|
||||||
import * as graphlibJson from 'dagre-d3-es/src/graphlib/json.js';
|
|
||||||
import * as graphlib from 'dagre-d3-es/src/graphlib/index.js';
|
|
||||||
import insertMarkers from '../../rendering-elements/markers.js';
|
import insertMarkers from '../../rendering-elements/markers.js';
|
||||||
import { updateNodeBounds } from '../../rendering-elements/shapes/util.js';
|
import { insertNode, positionNode, clear as clearNodes } from '../../rendering-elements/nodes.js';
|
||||||
// import {
|
|
||||||
// clear as clearGraphlib,
|
|
||||||
// clusterDb,
|
|
||||||
// adjustClustersAndEdges,
|
|
||||||
// findNonClusterChild,
|
|
||||||
// sortNodesByHierarchy,
|
|
||||||
// } from './mermaid-graphlib.js';
|
|
||||||
import {
|
|
||||||
insertNode,
|
|
||||||
positionNode,
|
|
||||||
clear as clearNodes,
|
|
||||||
setNodeElem,
|
|
||||||
} from '../../rendering-elements/nodes.js';
|
|
||||||
import {
|
import {
|
||||||
insertCluster,
|
insertCluster,
|
||||||
clear as clearClusters,
|
clear as clearClusters,
|
||||||
@@ -27,13 +11,9 @@ import {
|
|||||||
insertEdge,
|
insertEdge,
|
||||||
clear as clearEdges,
|
clear as clearEdges,
|
||||||
} from '../../rendering-elements/edges.js';
|
} from '../../rendering-elements/edges.js';
|
||||||
import { log } from '$root/logger.js';
|
|
||||||
import { getSubGraphTitleMargins } from '../../../utils/subGraphTitleMargins.js';
|
|
||||||
import { getConfig } from '../../../diagram-api/diagramAPI.js';
|
import { getConfig } from '../../../diagram-api/diagramAPI.js';
|
||||||
|
|
||||||
const fixInterSections = (points, startNode, endNode) => {
|
const fixInterSections = (points, startNode, endNode) => {
|
||||||
console.log('Fixing intersections - ', points, startNode, endNode);
|
|
||||||
|
|
||||||
// Get the intersections
|
// Get the intersections
|
||||||
const startIntersection = startNode.intersect(points[1]);
|
const startIntersection = startNode.intersect(points[1]);
|
||||||
const endIntersection = endNode.intersect(points[points.length - 2]);
|
const endIntersection = endNode.intersect(points[points.length - 2]);
|
||||||
@@ -46,14 +26,14 @@ const fixInterSections = (points, startNode, endNode) => {
|
|||||||
|
|
||||||
const doRender = async (_elem, data4Layout, siteConfig, positions) => {
|
const doRender = async (_elem, data4Layout, siteConfig, positions) => {
|
||||||
const elem = _elem.insert('g').attr('class', 'root');
|
const elem = _elem.insert('g').attr('class', 'root');
|
||||||
const clusters = elem.insert('g').attr('class', 'clusters');
|
elem.insert('g').attr('class', 'clusters');
|
||||||
const edgePaths = elem.insert('g').attr('class', 'edgePaths');
|
const edgePaths = elem.insert('g').attr('class', 'edgePaths');
|
||||||
const edgeLabels = elem.insert('g').attr('class', 'edgeLabels');
|
const edgeLabels = elem.insert('g').attr('class', 'edgeLabels');
|
||||||
const nodes = elem.insert('g').attr('class', 'nodes');
|
const nodes = elem.insert('g').attr('class', 'nodes');
|
||||||
|
|
||||||
// Insert nodes, this will insert them into the dom and each node will get a size. The size is updated
|
// Insert nodes, this will insert them into the dom and each node will get a size. The size is updated
|
||||||
// to the abstract node and is later used by dagre for the layout
|
// to the abstract node and is later used by dagre for the layout
|
||||||
let freePos = 0;
|
|
||||||
const nodeDB = {};
|
const nodeDB = {};
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
data4Layout.nodes.map(async function (node) {
|
data4Layout.nodes.map(async function (node) {
|
||||||
@@ -83,30 +63,31 @@ const doRender = async (_elem, data4Layout, siteConfig, positions) => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
data4Layout.edges.forEach(function (edge) {
|
await Promise.all(
|
||||||
edge.x = edge?.x || 0;
|
data4Layout.edges.forEach(async function (edge) {
|
||||||
edge.y = edge?.y || 0;
|
edge.x = edge?.x || 0;
|
||||||
insertEdgeLabel(edgeLabels, edge);
|
edge.y = edge?.y || 0;
|
||||||
});
|
await insertEdgeLabel(edgeLabels, edge);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
// log.info('############################################# XXX');
|
// log.info('############################################# XXX');
|
||||||
// log.info('### Layout ### XXX');
|
// log.info('### Layout ### XXX');
|
||||||
// log.info('############################################# XXX');
|
// log.info('############################################# XXX');
|
||||||
|
|
||||||
// Position the nodes
|
// Position the nodes
|
||||||
await Promise.all(
|
|
||||||
data4Layout.nodes.map(async function (node) {
|
data4Layout.nodes.map((node) => {
|
||||||
if (node.isGroup) {
|
if (node.isGroup) {
|
||||||
positionCluster(node);
|
positionCluster(node);
|
||||||
} else {
|
} else {
|
||||||
positionNode(node);
|
positionNode(node);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
);
|
|
||||||
|
|
||||||
// Insert the edges and position the edge labels
|
// Insert the edges and position the edge labels
|
||||||
data4Layout.edges.forEach(function (edge) {
|
data4Layout.edges.forEach(function (edge) {
|
||||||
console.log('Edge: ', edge, nodes[edge.start]);
|
// console.log('Edge: ', edge, nodes[edge.start]);
|
||||||
// log.info('Edge ' + e.v + ' -> ' + e.w + ': ' + JSON.stringify(edge), edge);
|
// log.info('Edge ' + e.v + ' -> ' + e.w + ': ' + JSON.stringify(edge), edge);
|
||||||
|
|
||||||
edge.points = fixInterSections(
|
edge.points = fixInterSections(
|
||||||
@@ -123,7 +104,6 @@ const doRender = async (_elem, data4Layout, siteConfig, positions) => {
|
|||||||
data4Layout.diagramId
|
data4Layout.diagramId
|
||||||
);
|
);
|
||||||
paths.updatedPath = paths.originalPath;
|
paths.updatedPath = paths.originalPath;
|
||||||
console.log('Paths = ', paths);
|
|
||||||
positionEdgeLabel(edge, paths);
|
positionEdgeLabel(edge, paths);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -239,15 +219,8 @@ const doRender = async (_elem, data4Layout, siteConfig, positions) => {
|
|||||||
* ###############################################################
|
* ###############################################################
|
||||||
* Render the graph
|
* Render the graph
|
||||||
* ###############################################################
|
* ###############################################################
|
||||||
* @param data4Layout
|
|
||||||
* @param svg
|
|
||||||
* @param element
|
|
||||||
* @param algoritm
|
|
||||||
* @param algorithm
|
|
||||||
* @param positions
|
|
||||||
*/
|
*/
|
||||||
export const render = async (data4Layout, svg, element, algorithm, positions) => {
|
export const render = async (data4Layout, svg, element, algorithm, positions) => {
|
||||||
console.log('Graph in render, positions: ', positions);
|
|
||||||
// Org
|
// Org
|
||||||
insertMarkers(element, data4Layout.markers, data4Layout.type, data4Layout.diagramId);
|
insertMarkers(element, data4Layout.markers, data4Layout.type, data4Layout.diagramId);
|
||||||
clearNodes();
|
clearNodes();
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import { createText } from '$root/rendering-util/createText.ts';
|
|||||||
import utils from '$root/utils.js';
|
import utils from '$root/utils.js';
|
||||||
import { getLineFunctionsWithOffset } from '$root/utils/lineWithOffset.js';
|
import { getLineFunctionsWithOffset } from '$root/utils/lineWithOffset.js';
|
||||||
import { getSubGraphTitleMargins } from '$root/utils/subGraphTitleMargins.js';
|
import { getSubGraphTitleMargins } from '$root/utils/subGraphTitleMargins.js';
|
||||||
import { curveBasis, curveLinear, curveCardinal, line, select } from 'd3';
|
// import { curveBasis, curveLinear, curveCardinal, line, select } from 'd3';
|
||||||
|
import { curveBasis, line, select } from 'd3';
|
||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
import createLabel from './createLabel.js';
|
import createLabel from './createLabel.js';
|
||||||
import { addEdgeMarkers } from './edgeMarker.ts';
|
import { addEdgeMarkers } from './edgeMarker.ts';
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js';
|
import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js';
|
||||||
import intersect from '../intersect/index.js';
|
import intersect from '../intersect/index.js';
|
||||||
import { select } from 'd3';
|
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import type { Node, RectOptions } from '$root/rendering-util/types.d.ts';
|
import type { Node, RectOptions } from '$root/rendering-util/types.d.ts';
|
||||||
import { drawRect } from './drawRect.js';
|
import { drawRect } from './drawRect.js';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
|
||||||
|
|
||||||
export const roundedRect = async (parent: SVGAElement, node: Node) => {
|
export const roundedRect = async (parent: SVGAElement, node: Node) => {
|
||||||
const { look } = getConfig();
|
|
||||||
const options = {
|
const options = {
|
||||||
rx: node.look === 'neo' ? 3 : 5,
|
rx: node.look === 'neo' ? 3 : 5,
|
||||||
ry: node.look === 'neo' ? 3 : 5,
|
ry: node.look === 'neo' ? 3 : 5,
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import type { Node, RectOptions } from '$root/rendering-util/types.d.ts';
|
import type { Node, RectOptions } from '$root/rendering-util/types.d.ts';
|
||||||
import { drawRect } from './drawRect.js';
|
import { drawRect } from './drawRect.js';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
|
||||||
|
|
||||||
export const state = async (parent: SVGAElement, node: Node) => {
|
export const state = async (parent: SVGAElement, node: Node) => {
|
||||||
const { look } = getConfig();
|
|
||||||
const options = {
|
const options = {
|
||||||
rx: node.look === 'neo' ? 3 : 5,
|
rx: node.look === 'neo' ? 3 : 5,
|
||||||
ry: node.look === 'neo' ? 3 : 5,
|
ry: node.look === 'neo' ? 3 : 5,
|
||||||
|
|||||||
@@ -37,11 +37,10 @@ export const createSubroutinePathD = (
|
|||||||
|
|
||||||
export const subroutine = async (parent: SVGAElement, node: Node) => {
|
export const subroutine = async (parent: SVGAElement, node: Node) => {
|
||||||
const { themeVariables } = getConfig();
|
const { themeVariables } = getConfig();
|
||||||
const { useGradient, mainBkg } = themeVariables;
|
const { useGradient } = themeVariables;
|
||||||
const { labelStyles, nodeStyles } = styles2String(node);
|
const { labelStyles, nodeStyles } = styles2String(node);
|
||||||
node.labelStyle = labelStyles;
|
node.labelStyle = labelStyles;
|
||||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
||||||
const halfPadding = (node?.padding || 8) / 2;
|
|
||||||
const nodePadding = node?.padding || 8;
|
const nodePadding = node?.padding || 8;
|
||||||
// const labelPaddingX = node.padding;
|
// const labelPaddingX = node.padding;
|
||||||
// const labelPaddingY = node.padding;
|
// const labelPaddingY = node.padding;
|
||||||
@@ -51,8 +50,7 @@ export const subroutine = async (parent: SVGAElement, node: Node) => {
|
|||||||
const h = bbox.height + labelPaddingY;
|
const h = bbox.height + labelPaddingY;
|
||||||
const x = -bbox.width / 2 - labelPaddingX / 2;
|
const x = -bbox.width / 2 - labelPaddingX / 2;
|
||||||
const y = -bbox.height / 2 - labelPaddingY / 2;
|
const y = -bbox.height / 2 - labelPaddingY / 2;
|
||||||
let rect;
|
|
||||||
const { cssStyles } = node;
|
|
||||||
const points = [
|
const points = [
|
||||||
{ x: 0, y: 0 },
|
{ x: 0, y: 0 },
|
||||||
{ x: w, y: 0 },
|
{ x: w, y: 0 },
|
||||||
@@ -78,7 +76,7 @@ export const subroutine = async (parent: SVGAElement, node: Node) => {
|
|||||||
// options.strokeWidth = 0
|
// options.strokeWidth = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
const roughNode = rc.rectangle(x - 8, y, w + 16, h, options);
|
rc.rectangle(x - 8, y, w + 16, h, options);
|
||||||
const l1 = rc.line(x, y, x, y + h, options);
|
const l1 = rc.line(x, y, x, y + h, options);
|
||||||
const l2 = rc.line(x + w, y, x + w, y + h, options);
|
const l2 = rc.line(x + w, y, x + w, y + h, options);
|
||||||
|
|
||||||
@@ -86,7 +84,7 @@ export const subroutine = async (parent: SVGAElement, node: Node) => {
|
|||||||
const l2El = shapeSvg.insert(() => l2, ':first-child');
|
const l2El = shapeSvg.insert(() => l2, ':first-child');
|
||||||
l1El.attr('class', 'neo-line');
|
l1El.attr('class', 'neo-line');
|
||||||
l2El.attr('class', 'neo-line');
|
l2El.attr('class', 'neo-line');
|
||||||
rect = shapeSvg.insert(() => roughNode, ':first-child');
|
// rect = shapeSvg.insert(() => roughNode, ':first-child');
|
||||||
|
|
||||||
// rect.attr('class', 'basic label-container').attr('style', cssStyles);
|
// rect.attr('class', 'basic label-container').attr('style', cssStyles);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { darken, lighten, adjust, invert, isDark, toRgba } from 'khroma';
|
import { darken, lighten, adjust, invert, isDark } from 'khroma';
|
||||||
import { mkBorder } from './theme-helpers.js';
|
import { mkBorder } from './theme-helpers.js';
|
||||||
import {
|
import {
|
||||||
oldAttributeBackgroundColorEven,
|
oldAttributeBackgroundColorEven,
|
||||||
|
|||||||
21082
pnpm-lock.yaml
generated
21082
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user