Revert "Split cytoscape"

This reverts commit f81f9f7c95.
This commit is contained in:
Sidharth Vinod
2023-02-28 20:31:03 +05:30
parent f8f7d94d5a
commit b8b8c4740a

View File

@@ -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');