mirror of
				https://github.com/mermaid-js/mermaid.git
				synced 2025-11-03 20:34:20 +01:00 
			
		
		
		
	Split cytoscape
This commit is contained in:
		@@ -186,7 +186,7 @@ export const addVertices = function (vert, svgId, root, doc, diagObj, parentLook
 | 
			
		||||
      default:
 | 
			
		||||
        _shape = 'rect';
 | 
			
		||||
    }
 | 
			
		||||
    // // Add the node
 | 
			
		||||
    // Add the node
 | 
			
		||||
    const node = {
 | 
			
		||||
      labelStyle: styles.labelStyle,
 | 
			
		||||
      shape: _shape,
 | 
			
		||||
 
 | 
			
		||||
@@ -4,13 +4,9 @@ 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';
 | 
			
		||||
 | 
			
		||||
// Inject the layout algorithm into cytoscape
 | 
			
		||||
cytoscape.use(coseBilkent);
 | 
			
		||||
 | 
			
		||||
let cytoscape;
 | 
			
		||||
/**
 | 
			
		||||
 * @param {any} svg The svg element to draw the diagram onto
 | 
			
		||||
 * @param {object} mindmap The mindmap data and hierarchy
 | 
			
		||||
@@ -93,7 +89,14 @@ function addNodes(mindmap, cy, conf, level) {
 | 
			
		||||
 * @param conf
 | 
			
		||||
 * @param cy
 | 
			
		||||
 */
 | 
			
		||||
function layoutMindmap(node, conf) {
 | 
			
		||||
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);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return new Promise((resolve) => {
 | 
			
		||||
    // Add temporary render element
 | 
			
		||||
    const renderEl = select('body').append('div').attr('id', 'cy').attr('style', 'display:none');
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user