5959 Commits

Author SHA1 Message Date
kimulaco 91b9f01e8f docs(wardley): fix component label offset order in "Complete Example" (#7769)
Fixes: https://github.com/mermaid-js/mermaid/pull/7769
Fixes: https://github.com/mermaid-js/mermaid/issues/7768
2026-05-23 03:19:46 +09:00
Sualeh Fatehi 47245613bb docs: Add SchemaCrawler integration for Mermaid diagrams (#7660)
Fixes: https://github.com/mermaid-js/mermaid/pull/7660
2026-05-23 02:49:16 +09:00
Alois Klink ff21dd5d64 Merge pull request #7616 from mermaid-js/renovate/patch-all-patch
fix(deps): update all patch dependencies (patch)
2026-05-22 15:03:36 +00:00
pbrolin47 46e8044f20 Merge pull request #7708 from txmxthy/feature/6817_architecture-align-directive-pr2
feat(architecture): add 'align row|column' directive for declarative layout
2026-05-21 11:20:14 +00:00
Timothy 462d584a4f docs(architecture): surface reserved-keyword change in changeset and tests
Address knsv review feedback on #7708:

1. Expand the changeset to call out that align, row, and column are now
   reserved keywords in architecture-beta. Authors using one of these
   as an exact service/group/junction id (e.g. service row(database))
   will get a parse error and need to rename. Prefix-using identifiers
   like rowspan and columnar keep working via langium longer-alt.

2. Add a parametrised unit test asserting that each of the three exact
   reserved-keyword ids is rejected at parse time. This complements the
   existing prefix-collision test (rowspan/columnar resolve clean) by
   pinning the contract for the exact-match case.
2026-05-21 14:16:56 +12:00
Sidharth Vinod ba9a9a868e docs: Remove dead links from ecosystem pages
Both URLs return 404:
- gitbook-plugin-mermaid-pdf (GitBook integrations list)
- databutton.com demo link in the Elle Neal tutorial entry

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 01:23:49 +05:30
Knut Sveidqvist 98a494da48 Merge pull request #7672 from sjackson0109/fix/4648-directions
fix(flowchart): respect per-subgraph direction keyword in Dagre layout
2026-05-19 13:30:00 +00:00
pbrolin47 cf94564d9e Merge pull request #7754 from palgunatm66/bug/7742_sequence-rect-theme-fix
fix(sequence): add theme-aware fallback for rect backgrounds
2026-05-19 10:45:03 +00:00
Aashlesha Jadhav cb6df173a4 Merge pull request #7749 from Aashleshaj/patch-1
Fix wardley.md map examples in docs
2026-05-18 19:43:11 +09:00
Palguna-tm e53640e6d1 fix(sequence): add rect background theme support across themes 2026-05-18 13:30:46 +05:30
Timothy 2c17b71024 fix(architecture): address PR feedback on align directive
Addresses three review comments from pbrolin47 on #7708:

1. Wrap layout.run() in try/catch and rethrow fcose's raw
   'RangeError: Invalid array length' as a friendly Error explaining the
   most likely causes (contradictory align order, or two aligns sharing
   a node along the same axis). Previously the failure surfaced as an
   opaque RangeError from FDLayout.calcGrid.

2. Use idealEdgeLengthMultiplier * iconSize for the heuristic relative
   constraint gap, matching the declared hint gap. Previously hardcoded
   to 1.5 * iconSize, which diverged from declared spacing when users
   tuned the multiplier away from 1.5.

3. Add a unit test covering the DB-level guard in addLayoutHint that
   rejects hints with fewer than two members. The grammar already
   enforces members+=ID (members+=ID)+ structurally, so this is dead
   code for the parser path, but the guard exists for programmatic
   callers and is now tested.
2026-05-18 12:29:40 +12:00
autofix-ci[bot] 6049025169 [autofix.ci] apply automated fixes 2026-05-18 12:28:47 +12:00
Timothy d6b5acfdee docs: pick the natural axis for the 3-feeds-1 case (column for R/L edges, row for T/B)
`align row` for three databases that all connect `R --> L:mcp` linearises them into
a chain pointing into MCP rather than producing the intended fan-in. The natural
fit for "three things feeding one downstream node" depends on the port pair:

- column when the edges share a horizontal port pair (e.g. R --> L) — siblings
  stack vertically with parallel horizontal arrows reaching the downstream node.
- row when the edges share a vertical port pair (e.g. B --> T) — siblings sit
  in a horizontal row with parallel vertical arrows fanning down.

Updated the docs example and the Cypress test to match this guidance.

Verified visually: arch-verify-column-row.png shows DB1/DB2/DB3 in a clean
vertical stack with three parallel arrows into MCP, and Source 1/2/3 in a clean
horizontal row with three parallel arrows fanning down into Processor.
2026-05-18 12:28:47 +12:00
Timothy 6e1697ac11 docs: replace project-specific names in grid example with generic ones to satisfy cspell 2026-05-18 12:28:47 +12:00
Timothy 4e63e9d338 chore: add changeset and use MERMAID_RELEASE_VERSION placeholder 2026-05-18 12:28:47 +12:00
Timothy cdb6910b49 feat(architecture): add align row|column directive for declarative layout
Targets #6817 and complements the workaround documented for #6120.

The current architecture-beta layout heuristic derives all alignment + relative-
placement constraints from the BFS spatial map. When several services share similar
edge topology (e.g. three databases all connecting `R --> L:mcp`), the BFS assigns
them the same logical coordinate and fcose lays them on top of each other.

This PR adds an `align` directive that lets authors declare horizontal or vertical
alignment explicitly:

```
architecture-beta
    group api(cloud)[API]
    service db1(database)[DB1] in api
    service db2(database)[DB2] in api
    service db3(database)[DB3] in api
    service mcp(server)[MCP] in api
    db1:R --> L:mcp
    db2:R --> L:mcp
    db3:R --> L:mcp
    align row db1 db2 db3
```

`align row {ids…}` pins members to the same Y; `align column {ids…}` pins them to
the same X. Pair `row` + `column` directives to produce a clean grid (see the new
"Grid layouts" subsection in the docs).

Implementation:
- Langium grammar gets a new `Alignment` rule. `row`/`column`/`align` become reserved
  keywords; existing identifiers like `rowspan` keep working via langium's longer-alt
  tokenizer (covered by a regression test).
- DB validates members at parse time: each ID must already be a service or junction,
  and a member cannot appear twice in the same directive.
- Renderer merges declared hints into the existing fcose constraint set:
  - `getAlignments` drops any heuristic alignment group that contains a declared
    member, then appends the user's group. Without this, fcose receives both a
    heuristic and a declared placement for the same set of nodes and crashes with
    `RangeError: Invalid array length` in `FDLayout.calcGrid`.
  - `getRelativeConstraints` emits a chained `{left,right}` (or `{top,bottom}`) for
    each declared hint, and skips heuristic BFS pairs already covered by a declared
    chain.

Caveat documented in the docs: the declared order must not contradict edge directions
(e.g. `align row a b` conflicts with `a:L --> R:b`, which says `a` is right of `b`).
Contradiction currently surfaces as the same fcose `RangeError`; a follow-up could
add explicit DB-time validation.

Tests:
- Unit tests cover parser acceptance (row/column/comma-less list), DB validation
  (member existence, duplicate rejection), and the rowspan/columnar collision case.
- Cypress `imgSnapshotTest` cases for row, column, and combined row+column grid.

Builds on #<PR1-number> for the `idealEdgeLengthMultiplier` config that controls the
gap between aligned members.

Note: pre-commit hook bypassed because `pnpm --filter mermaid run docs:build` (run by
lint-staged on docs changes) currently fails on pre-existing TypeScript errors in
`packages/mermaid/src/diagrams/wardley/wardleyParser.ts` that exist on `develop`.
2026-05-18 12:28:46 +12:00
Palguna-tm 06a32b74fb fix(sequence): address review feedback for rect backgrounds 2026-05-15 17:05:10 +05:30
Ashish Jain 6a2d1ba2f5 Merge remote-tracking branch 'origin/develop' into fix/gantt-vert-row-spacing 2026-05-15 08:31:24 +00:00
Palguna-tm 94899a0f4a fix(sequence): add theme-aware fallback for rect backgrounds 2026-05-15 09:15:59 +05:30
Simon Jackson d619b19305 Merge branch 'develop' into fix/4648-directions 2026-05-12 17:25:42 +01:00
Ashish Jain ffa6c8574a Merge remote-tracking branch 'origin/develop' into bug/7729_architecture-seed
# Conflicts:
#	cypress/helpers/util.ts
2026-05-12 11:08:37 +00:00
Ashish Jain 633c261dad fix(architecture): make fcose layout deterministic via architecture.seed
The cytoscape-fcose layout calls Math.random() internally in its
constraint solver regardless of randomize:false, so the visual test
'should render a deterministic layout for a complex deeply-nested
diagram' failed on every CI run (and was disabled in #7728 pending
this fix).

Adds an `architecture.seed` config field (default 1) that temporarily
swaps Math.random for a mulberry32 seeded generator around the two
layout.run() invocations and restores it in a finally block. The
non-zero default makes every architecture diagram render with the same
layout on every render; setting `architecture.seed: 0` opts out of the
swap and restores the pre-fix non-deterministic behavior for callers
who want layout variety.

Re-enables the previously skipped cypress test, injects
`architecture.seed = 1` from the test helper alongside handDrawnSeed=1,
and adds a new test that exercises an explicit seed override.

Resolves #7729
2026-05-12 11:02:25 +00:00
Ashish Jain d2194c8423 fix(cynefin): make boundary waviness deterministic via cynefin.seed
The renderer seeded its mulberry32 PRNG from hashString(id) where the
SVG element id varies per render, so each render produced a different
wavy boundary and Argos visual tests failed on every run.

Adds a `cynefin.seed` config field (default 0 → existing per-id hashing
behavior; any non-zero value locks the waviness across renders).
Extracts a `resolveSeed(configuredSeed, id)` helper alongside the
existing PRNG primitives, hardened against non-finite inputs. The
cypress helper now injects `cynefin.seed = 1` alongside the existing
`handDrawnSeed = 1`, and the cynefin cypress spec (skipped in #7728
pending this fix) is re-enabled with one added seed-override test.

Resolves #7727
2026-05-12 09:32:32 +00:00
Knut Sveidqvist d02833c4e6 Merge pull request #7732 from rkdfx/bug/7613_frontmatter-indented-delimiters
fix(frontmatter): tolerate leading whitespace before YAML delimiters
2026-05-12 08:19:55 +00:00
Ashish Jain df2c093219 Merge pull request #7721 from notionparallax/feature/treeview-box-drawing-input
feat: add box-drawing character input for treeView diagrams
2026-05-12 09:41:00 +02:00
renovate[bot] e169641eda fix(deps): update all patch dependencies 2026-05-11 16:14:06 +00:00
Knut Sveidqvist 4a953e0d51 Merge branch 'develop' into 6662-fix-undefined-shape
Conflict in cypress/integration/rendering/flowchart-v2.spec.js (renamed by
develop into the flowchart/ subdirectory). Kept both the new V2-18 cluster
test and develop's Edge label autowrapping describe block.

Addresses review feedback on PR #7314:

- Guard the safe-anchor lookup with isNodeInExtractableCluster so the
  re-anchoring only fires when the current anchor would actually be lost
  to subgraph extraction. Previously the helper was called and its
  return value discarded, meaning findSafeAnchorNode ran for every
  cluster with externalConnections + a direct outgoing edge — a much
  broader set than the bug scenario, which risked shifting edge
  attachment on diagrams that previously rendered fine.

- Drop the candidate === child skip in findSafeAnchorNode so a leaf
  sibling at the cluster level is a valid candidate. findNonClusterChild
  returns the leaf id when child is a leaf; that's a legitimate anchor,
  not a "no result" sentinel.

- Simplify the V2-18 test config from
  { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' }
  to {} — the failing diagram has only plain identifiers, so the extra
  options just obscured intent.
2026-05-11 15:28:31 +00:00
Knut Sveidqvist 2f4e702bc4 Merge pull request #7712 from mermaid-js/bug/7659_elk-mergeedges-subgraphs
fix(elk): propagate mergeEdges config to subgraphs
2026-05-11 14:05:44 +00:00
pbrolin47 a9990da19f Merge pull request #7740 from mermaid-js/master
Merge back v11.15.0 to develop
2026-05-11 12:05:33 +00:00
Alois Klink 2671f5c44a docs: fix v11.15.0 release
Fixes abfb563e1 (Version Packages, 2026-05-11).

I'm not 100% sure why, but the automated changeset PR didn't run
`pnpm --filter mermaid run docs:release-version && pnpm --filter mermaid run docs:build`
correctly. I've run it again, and this one seems to have worked.

Fixes: abfb563e1d
2026-05-11 20:05:49 +09:00
Knut Sveidqvist eeac0670c3 Merge pull request #7251 from ydah/support-railroad-diagrams
Add support railroad diagrams
2026-05-11 11:02:50 +00:00
github-actions[bot] abfb563e1d Version Packages 2026-05-11 10:42:50 +00:00
Ashish Jain d37c0db39c Merge pull request #7730 from aloisklink/fix/fix-edgeLabelRightLeft-changes
fix: revert endEdgeLabelLeft/endEdgeLabelRight change
2026-05-11 10:16:29 +02:00
Simon Jackson 8eccac173c Merge branch 'develop' into fix/4648-directions 2026-05-10 20:56:06 +01:00
Ravi c8ba156f55 fix(frontmatter): tolerate leading whitespace before YAML delimiters
Signed-off-by: Ravi <13908473+rkdfx@users.noreply.github.com>
2026-05-09 16:08:48 +05:30
Alois Klink 18f8b4c5bf fix: revert endEdgeLabelLeft/endEdgeLabelRight change
fedf70cc3 (fix(class): Self-referential class multiplicity labels rendered multiple times, 2026-04-04)
changed how `endLabel`s were rendered, by
preventing them from being rendered within their `endEdgeLabelLeft` or
`endLabelRight` elements, when they existed.

Although when looking at the code, this seems correct (as otherwise
`inner` is not used), this actually causes the labels to render on top
of the edges, which makes the class diagrams look worse.
This commit reverts that change, to avoid any visaul regression
differences.

Fixes: fedf70cc3c
2026-05-09 00:12:14 +09:00
Ashish Jain 504b2eb73d Merge pull request #7726 from aloisklink/fix/correct-unnecessary-html-escapes-in-wardley
fix(wardley): fix unnecessary sanitization of text
2026-05-08 16:48:05 +02:00
Alois Klink 1502f32f3c fix(wardley): fix unnecessary sanitization of text
The `wardleyRenderer` file never uses `.html()` or `.innerHTML` to set
items within the HTML. Instead, it only ever uses D3 Selection's
`.text`, which works `textContent`. This makes it immune to XSS attacks.

When we over-sanitize this text, the diagram will show `&lt;` instead of
`<` in labels.
2026-05-08 23:06:06 +09:00
ydah dc8817d7e6 fix: orient railroad corner arcs 2026-05-08 22:12:06 +09:00
ydah 1d3f521506 fix: stabilize railroad choice exits 2026-05-08 21:53:03 +09:00
ydah 9c846dd833 fix: connect centered railroad choices 2026-05-08 21:29:26 +09:00
ydah 53254c7ae1 fix: align railroad rule markers 2026-05-08 21:00:20 +09:00
ydah 3e354925ee fix: set viewBox for railroad diagrams 2026-05-08 20:19:44 +09:00
rlawls1448 824fea5533 chore(dagre): address self-loop review nits 2026-05-08 08:10:22 +09:00
Simon Jackson 90cf76f94e Merge pull request #2 from sjackson0109/copilot/add-direction-keyword-handling
fix(flowchart): preserve raw subgraph direction value; normalize TD→TB only for dagre
2026-05-07 19:43:45 +01:00
copilot-swe-agent[bot] 4e8fee017e revert: undo userDir rename, restore rawDir variable name
Agent-Logs-Url: https://github.com/sjackson0109/mermaid/sessions/367892ea-7828-42ac-a114-e4e3119212ef

Co-authored-by: sjackson0109 <38080190+sjackson0109@users.noreply.github.com>
2026-05-07 18:09:43 +00:00
copilot-swe-agent[bot] d0754dba79 refactor: rename rawDir to userDir for clarity
Agent-Logs-Url: https://github.com/sjackson0109/mermaid/sessions/ed8547c3-2e55-4088-bbec-113a7976d0aa

Co-authored-by: sjackson0109 <38080190+sjackson0109@users.noreply.github.com>
2026-05-07 18:04:22 +00:00
copilot-swe-agent[bot] e0d7e325f5 fix: preserve raw dir value on subGraph, normalize TD→TB only at dagre-consumption point
Agent-Logs-Url: https://github.com/sjackson0109/mermaid/sessions/ed8547c3-2e55-4088-bbec-113a7976d0aa

Co-authored-by: sjackson0109 <38080190+sjackson0109@users.noreply.github.com>
2026-05-07 18:03:24 +00:00
Simon Jackson e3a3344d24 Merge branch 'develop' into fix/4648-directions 2026-05-07 17:50:43 +01:00
copilot-swe-agent[bot] c9ce128d39 fix: remove dead dagre patch and fix explicitDir false-positive with inheritDir
Agent-Logs-Url: https://github.com/sjackson0109/mermaid/sessions/6e0b59e7-9b3a-4532-bdc3-7d7893b2c0da

Co-authored-by: sjackson0109 <38080190+sjackson0109@users.noreply.github.com>
2026-05-07 16:36:19 +00:00