From b8b8c4740a00e208672a3c319c19a5c83c87168e Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Tue, 28 Feb 2023 20:31:03 +0530 Subject: [PATCH] Revert "Split cytoscape" This reverts commit f81f9f7c958848758d26e1e2bf05a98808152a25. --- .../src/diagrams/mindmap/mindmapRenderer.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/mermaid/src/diagrams/mindmap/mindmapRenderer.js b/packages/mermaid/src/diagrams/mindmap/mindmapRenderer.js index 0d814212e2..0e68a10154 100644 --- a/packages/mermaid/src/diagrams/mindmap/mindmapRenderer.js +++ b/packages/mermaid/src/diagrams/mindmap/mindmapRenderer.js @@ -4,9 +4,13 @@ import { log } from '../../logger'; import { getConfig } from '../../config'; import { setupGraphViewbox } from '../../setupGraphViewbox'; import svgDraw from './svgDraw'; +import cytoscape from 'cytoscape'; +import coseBilkent from 'cytoscape-cose-bilkent'; import * as db from './mindmapDb'; -let cytoscape; +// Inject the layout algorithm into cytoscape +cytoscape.use(coseBilkent); + /** * @param {any} svg The svg element to draw the diagram onto * @param {object} mindmap The mindmap data and hierarchy @@ -89,14 +93,7 @@ function addNodes(mindmap, cy, conf, level) { * @param conf * @param cy */ -async function layoutMindmap(node, conf) { - if (!cytoscape) { - cytoscape = (await import('cytoscape')).default; - const coseBilkent = (await import('cytoscape-cose-bilkent')).default; - // Inject the layout algorithm into cytoscape - cytoscape.use(coseBilkent); - } - +function layoutMindmap(node, conf) { return new Promise((resolve) => { // Add temporary render element const renderEl = select('body').append('div').attr('id', 'cy').attr('style', 'display:none');