mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-26 10:49:38 +02:00
Merge branch 'release_9.2.0_buggfixes' into sidv/TSMindmap
* release_9.2.0_buggfixes: Color fix for default nodes in mindmap, line uses inv color
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mermaid-js/mermaid-mindmap",
|
||||
"version": "9.2.0-rc3",
|
||||
"version": "9.2.0-rc4",
|
||||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
|
||||
"main": "dist/mermaid-mindmap.core.mjs",
|
||||
"module": "dist/mermaid-mindmap.core.mjs",
|
||||
|
@@ -17,11 +17,9 @@ interface Node {
|
||||
|
||||
let nodes: Node[] = [];
|
||||
let cnt = 0;
|
||||
let elements: Record<number, HTMLElement> = {};
|
||||
export const clear = () => {
|
||||
nodes = [];
|
||||
cnt = 0;
|
||||
elements = {};
|
||||
};
|
||||
|
||||
const getParent = function (level: number) {
|
||||
@@ -107,10 +105,6 @@ export const getType = (startStr: string, endStr: string): number => {
|
||||
}
|
||||
};
|
||||
|
||||
export const setElementForId = (id: number, element: HTMLElement) => {
|
||||
elements[id] = element;
|
||||
};
|
||||
|
||||
export const decorateNode = (decoration: { icon: string; class: string }) => {
|
||||
const node = nodes[nodes.length - 1];
|
||||
if (decoration && decoration.icon) {
|
||||
@@ -150,5 +144,3 @@ export const setErrorHandler = (handler: ParseErrorFunction) => {
|
||||
export const getLogger = () => log;
|
||||
|
||||
export const getNodeById = (id: number): Node => nodes[id];
|
||||
export const getElementById = (id: number | string): HTMLElement =>
|
||||
elements[typeof id === 'string' ? parseInt(id) : id];
|
||||
|
@@ -1,10 +1,9 @@
|
||||
/** Created by knut on 23-07-2022. */
|
||||
import { select } from 'd3';
|
||||
import { log, getConfig, setupGraphViewbox } from './mermaidUtils';
|
||||
import svgDraw from './svgDraw';
|
||||
import svgDraw, { getElementById, clearElementRefs } from './svgDraw';
|
||||
import cytoscape from 'cytoscape';
|
||||
import coseBilkent from 'cytoscape-cose-bilkent';
|
||||
import * as db from './mindmapDb';
|
||||
|
||||
// Inject the layout algorithm into cytoscape
|
||||
cytoscape.use(coseBilkent);
|
||||
@@ -155,7 +154,7 @@ function positionNodes(cy) {
|
||||
data.x = node.position().x;
|
||||
data.y = node.position().y;
|
||||
svgDraw.positionNode(data);
|
||||
const el = db.getElementById(data.nodeId);
|
||||
const el = getElementById(data.nodeId);
|
||||
log.info('Id:', id, 'Position: (', node.position().x, ', ', node.position().y, ')', data);
|
||||
el.attr(
|
||||
'transform',
|
||||
@@ -179,6 +178,7 @@ export const draw = async (text, id, version, diagObj) => {
|
||||
|
||||
// This is done only for throwing the error if the text is not valid.
|
||||
diagObj.db.clear();
|
||||
clearElementRefs();
|
||||
// Parse the graph definition
|
||||
diagObj.parser.parse(text);
|
||||
|
||||
|
@@ -27,6 +27,7 @@ const genSections = (options) => {
|
||||
.node-icon-${i - 1} {
|
||||
font-size: 40px;
|
||||
color: ${options['cScaleLabel' + i]};
|
||||
// fill: ${options['cScaleLabel' + i]};
|
||||
// color: ${options['gitInv' + i]};
|
||||
}
|
||||
.section-edge-${i - 1}{
|
||||
@@ -36,7 +37,7 @@ const genSections = (options) => {
|
||||
stroke-width: ${sw};
|
||||
}
|
||||
.section-${i - 1} line {
|
||||
stroke: ${options['lineColor' + i]} ;
|
||||
stroke: ${options['cScaleInv' + i]} ;
|
||||
stroke-width: 3;
|
||||
}
|
||||
|
||||
|
@@ -259,7 +259,7 @@ export const drawNode = function (elem, node, fullSection, conf) {
|
||||
// if (typeof node.x !== 'undefined' && typeof node.y !== 'undefined') {
|
||||
// nodeElem.attr('transform', 'translate(' + node.x + ',' + node.y + ')');
|
||||
// }
|
||||
db.setElementForId(node.id, nodeElem);
|
||||
setElementById(node.id, nodeElem);
|
||||
return node.height;
|
||||
};
|
||||
|
||||
@@ -286,7 +286,7 @@ export const drawEdge = function drawEdge(edgesElem, mindmap, parent, depth, ful
|
||||
};
|
||||
|
||||
export const positionNode = function (node) {
|
||||
const nodeElem = db.getElementById(node.id);
|
||||
const nodeElem = getElementById(node.id);
|
||||
|
||||
const x = node.x || 0;
|
||||
const y = node.y || 0;
|
||||
@@ -294,4 +294,18 @@ export const positionNode = function (node) {
|
||||
nodeElem.attr('transform', 'translate(' + x + ',' + y + ')');
|
||||
};
|
||||
|
||||
let elements = {};
|
||||
|
||||
const setElementById = (id, element) => {
|
||||
elements[id] = element;
|
||||
};
|
||||
|
||||
export const getElementById = (id) => {
|
||||
return elements[id];
|
||||
};
|
||||
|
||||
export const clearElementRefs = () => {
|
||||
elements = {};
|
||||
};
|
||||
|
||||
export default { drawNode, positionNode, drawEdge };
|
||||
|
@@ -455,10 +455,11 @@ const handleDirective = function (p: any, directive: any, type: string): void {
|
||||
/** @param {MermaidConfig} options */
|
||||
async function initialize(options: MermaidConfig) {
|
||||
// Handle legacy location of font-family configuration
|
||||
if (options?.fontFamily) {
|
||||
if (!options.themeVariables?.fontFamily) {
|
||||
options.themeVariables = { fontFamily: options.fontFamily };
|
||||
if (options.fontFamily) {
|
||||
if (!options.themeVariables) {
|
||||
options.themeVariables = {};
|
||||
}
|
||||
options.themeVariables.fontFamily = options.fontFamily;
|
||||
}
|
||||
|
||||
// Set default options
|
||||
|
Reference in New Issue
Block a user