diff --git a/packages/mermaid/src/diagrams/state/stateDb.js b/packages/mermaid/src/diagrams/state/stateDb.js index 52d797d8b..1f12425e6 100644 --- a/packages/mermaid/src/diagrams/state/stateDb.js +++ b/packages/mermaid/src/diagrams/state/stateDb.js @@ -12,6 +12,7 @@ import { getDiagramTitle, } from '../common/commonDb.js'; import { dataFetcher, reset as resetDataFetching } from './dataFetcher.js'; +import { getDir } from './stateRenderer-v3-unified.js'; import { DEFAULT_DIAGRAM_DIRECTION, @@ -588,7 +589,7 @@ const trimColon = (str) => (str && str[0] === ':' ? str.substr(1).trim() : str.t export const getData = () => { const config = getConfig(); - return { nodes, edges, other: {}, config }; + return { nodes, edges, other: {}, config, direction: getDir(getRootDocV2()) }; }; export default { diff --git a/packages/mermaid/src/diagrams/state/stateRenderer-v3-unified.ts b/packages/mermaid/src/diagrams/state/stateRenderer-v3-unified.ts index 82e4b4197..9ad666655 100644 --- a/packages/mermaid/src/diagrams/state/stateRenderer-v3-unified.ts +++ b/packages/mermaid/src/diagrams/state/stateRenderer-v3-unified.ts @@ -16,7 +16,7 @@ import { CSS_DIAGRAM, DEFAULT_NESTED_DOC_DIR } from './stateCommon.js'; * @param defaultDir - the direction to use if none is found * @returns The direction to use */ -const getDir = (parsedItem: any, defaultDir = DEFAULT_NESTED_DOC_DIR) => { +export const getDir = (parsedItem: any, defaultDir = DEFAULT_NESTED_DOC_DIR) => { let dir = defaultDir; if (parsedItem.doc) { for (const parsedItemDoc of parsedItem.doc) { @@ -44,7 +44,7 @@ export const draw = async function (text: string, id: string, _version: string, // Not related to the refactoring, but this is the first step in the rendering process diag.db.extract(diag.db.getRootDocV2()); - const DIR = getDir(diag.db.getRootDocV2()); + //const DIR = getDir(diag.db.getRootDocV2()); // The getData method provided in all supported diagrams is used to extract the data from the parsed structure // into the Layout data format @@ -66,7 +66,6 @@ export const draw = async function (text: string, id: string, _version: string, data4Layout.type = diag.type; data4Layout.layoutAlgorithm = layout; - data4Layout.direction = DIR; // TODO: Should we move these two to baseConfig? These types are not there in StateConfig. @@ -89,4 +88,5 @@ export const draw = async function (text: string, id: string, _version: string, export default { getClasses, draw, + getDir, };