Merge branch '5237-unified-layout-common-renderer' of github.com:mermaid-js/mermaid into 5237-unified-layout-common-renderer

This commit is contained in:
Knut Sveidqvist
2024-07-03 11:35:05 +02:00
2 changed files with 5 additions and 4 deletions

View File

@@ -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 {

View File

@@ -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,
};