mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-25 18:30:10 +02:00
@@ -4,9 +4,13 @@ import { log } from '../../logger';
|
|||||||
import { getConfig } from '../../config';
|
import { getConfig } from '../../config';
|
||||||
import { setupGraphViewbox } from '../../setupGraphViewbox';
|
import { setupGraphViewbox } from '../../setupGraphViewbox';
|
||||||
import svgDraw from './svgDraw';
|
import svgDraw from './svgDraw';
|
||||||
|
import cytoscape from 'cytoscape';
|
||||||
|
import coseBilkent from 'cytoscape-cose-bilkent';
|
||||||
import * as db from './mindmapDb';
|
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 {any} svg The svg element to draw the diagram onto
|
||||||
* @param {object} mindmap The mindmap data and hierarchy
|
* @param {object} mindmap The mindmap data and hierarchy
|
||||||
@@ -89,14 +93,7 @@ function addNodes(mindmap, cy, conf, level) {
|
|||||||
* @param conf
|
* @param conf
|
||||||
* @param cy
|
* @param cy
|
||||||
*/
|
*/
|
||||||
async function layoutMindmap(node, conf) {
|
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) => {
|
return new Promise((resolve) => {
|
||||||
// Add temporary render element
|
// Add temporary render element
|
||||||
const renderEl = select('body').append('div').attr('id', 'cy').attr('style', 'display:none');
|
const renderEl = select('body').append('div').attr('id', 'cy').attr('style', 'display:none');
|
||||||
|
Reference in New Issue
Block a user