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