Skip to content

Commit

Permalink
#5237 Make getData to use global nodes and edges
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishjain0512 committed Jun 12, 2024
1 parent 50394e7 commit d895a62
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions packages/mermaid/src/diagrams/state/stateDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
};

/**
Expand Down Expand Up @@ -306,6 +316,8 @@ export const addState = function (
};

export const clear = function (saveCommon) {
nodes = [];
edges = [];
documents = {
root: newDoc(),
};
Expand Down Expand Up @@ -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 };
};

Expand Down

0 comments on commit d895a62

Please sign in to comment.