#5237 Make getData to use global nodes and edges

This commit is contained in:
Ashish Jain
2024-06-12 11:05:26 +02:00
parent 50394e7af1
commit d895a62565

View File

@@ -71,6 +71,9 @@ function newClassesList() {
return new Map();
}
let nodes = [];
let edges = [];
let direction = DEFAULT_DIAGRAM_DIRECTION;
let rootDoc = [];
let classes = newClassesList(); // style classes defined by a classDef
@@ -222,6 +225,13 @@ const extract = (_doc) => {
break;
}
});
const diagramStates = getStates();
const config = getConfig();
const useRough = config.look === 'handdrawn';
const look = config.look;
resetDataFetching();
dataFetcher(undefined, getRootDocV2(), diagramStates, nodes, edges, true, useRough, look);
};
/**
@@ -306,6 +316,8 @@ export const addState = function (
};
export const clear = function (saveCommon) {
nodes = [];
edges = [];
documents = {
root: newDoc(),
};
@@ -571,20 +583,7 @@ const setDirection = (dir) => {
const trimColon = (str) => (str && str[0] === ':' ? str.substr(1).trim() : str.trim());
export const getData = () => {
const nodes = [];
const edges = [];
// for (const key in currentDocument.states) {
// if (currentDocument.states.hasOwnProperty(key)) {
// nodes.push({...currentDocument.states[key]});
// }
// }
const diagramStates = getStates();
const config = getConfig();
const useRough = config.look === 'handdrawn';
const look = config.look;
resetDataFetching();
dataFetcher(undefined, getRootDocV2(), diagramStates, nodes, edges, true, useRough, look);
return { nodes, edges, other: {}, config };
};