From 7e837dfee26808c08b72b85018f881301050356b Mon Sep 17 00:00:00 2001 From: Ashish Jain Date: Mon, 29 Apr 2024 15:58:54 +0200 Subject: [PATCH] #5237 add support for diagram title --- .../src/diagrams/state/stateRenderer-v3-unified.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/src/diagrams/state/stateRenderer-v3-unified.ts b/packages/mermaid/src/diagrams/state/stateRenderer-v3-unified.ts index a426a32a54..f8fd190198 100644 --- a/packages/mermaid/src/diagrams/state/stateRenderer-v3-unified.ts +++ b/packages/mermaid/src/diagrams/state/stateRenderer-v3-unified.ts @@ -18,6 +18,7 @@ import { DIVIDER_TYPE, CSS_DIAGRAM, } from './stateCommon.js'; +import utils from '../../utils.js'; // Configuration const conf: Record = {}; @@ -86,8 +87,8 @@ export const draw = async function (text: string, id: string, _version: string, // performRender(data4Rendering); data4Layout.type = diag.type; - // data4Layout.layoutAlgorithm = 'dagre-wrapper'; - data4Layout.layoutAlgorithm = 'elk'; + data4Layout.layoutAlgorithm = 'dagre-wrapper'; + //data4Layout.layoutAlgorithm = 'elk'; data4Layout.skin = 'roughjs'; data4Layout.direction = DIR; data4Layout.nodeSpacing = conf.nodeSpacing || 50; @@ -97,6 +98,12 @@ export const draw = async function (text: string, id: string, _version: string, console.log('REF1:', data4Layout); await render(data4Layout, svg, element); const padding = 8; + utils.insertTitle( + element, + 'statediagramTitleText', + conf.titleTopMargin, + diag.db.getDiagramTitle() + ); setupViewPortForSVG(svg, padding, CSS_DIAGRAM, conf.useMaxWidth); };