Fix support for fixed layout for flowchart

This commit is contained in:
Ashish Jain
2024-09-04 13:38:10 +02:00
parent 165a4f6825
commit 8fd57abc81

View File

@@ -16,7 +16,13 @@ export const getClasses = function (
return diagramObj.db.getClasses();
};
export const draw = async function (text: string, id: string, _version: string, diag: any) {
export const draw = async function (
text: string,
id: string,
_version: string,
diag: any,
positions: any
) {
log.info('REF0:');
log.info('Drawing state diagram (v2)', id);
const { securityLevel, flowchart: conf, layout } = getConfig();
@@ -41,6 +47,7 @@ export const draw = async function (text: string, id: string, _version: string,
data4Layout.type = diag.type;
data4Layout.layoutAlgorithm = getRegisteredLayoutAlgorithm(layout);
if (data4Layout.layoutAlgorithm === 'dagre' && layout === 'elk') {
log.warn(
'flowchart-elk was moved to an external package in Mermaid v11. Please refer [release notes](https://github.com/mermaid-js/mermaid/releases/tag/v11.0.0) for more details. This diagram will be rendered using `dagre` layout as a fallback.'
@@ -53,7 +60,7 @@ export const draw = async function (text: string, id: string, _version: string,
data4Layout.diagramId = id;
log.debug('REF1:', data4Layout);
await render(data4Layout, svg);
await render(data4Layout, svg, positions);
const padding = data4Layout.config.flowchart?.diagramPadding ?? 8;
utils.insertTitle(
svg,