Wrap Mermaid flowchart labels

Long Mermaid node labels rendered as a single constrained line, which
caused text to be clipped in risk assessment diagrams. Share a Mermaid
render configuration that enables flowchart label wrapping before layout
so nodes expand for multi-line labels.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

Co-authored-by: Sacha Al Himdani <SachaProbo@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-07-01 12:34:16 +00:00
parent 7142757dd8
commit 4cdf8b7913
3 changed files with 29 additions and 2 deletions

View File

@@ -15,6 +15,8 @@
import mermaid from "mermaid";
import { useEffect, useId, useState } from "react";
import { mermaidRenderConfig } from "../../mermaidConfig";
type Props = {
chart: string;
};
@@ -33,7 +35,7 @@ export function MermaidDiagram({ chart }: Props) {
let cancelled = false;
mermaid.initialize({ startOnLoad: false, theme: "neutral" });
mermaid.initialize(mermaidRenderConfig);
mermaid
.render(`mermaid-${id}`, source)

View File

@@ -8,6 +8,8 @@ import { NodeViewContent, NodeViewWrapper } from "@tiptap/react";
import mermaid from "mermaid";
import { useEffect, useId, useState } from "react";
import { mermaidRenderConfig } from "../mermaidConfig";
type MermaidMode = "code" | "preview";
function MermaidPreview({ chart }: { chart: string }) {
@@ -22,7 +24,7 @@ function MermaidPreview({ chart }: { chart: string }) {
let cancelled = false;
mermaid.initialize({ startOnLoad: false, theme: "neutral" });
mermaid.initialize(mermaidRenderConfig);
mermaid
.render(`mermaid-editor-${id}`, source)

View File

@@ -0,0 +1,23 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
export const mermaidRenderConfig = {
startOnLoad: false,
theme: "neutral",
htmlLabels: true,
markdownAutoWrap: true,
flowchart: {
wrappingWidth: 220,
},
} as const;