diff --git a/.changeset/public-things-stare.md b/.changeset/public-things-stare.md new file mode 100644 index 000000000..601450729 --- /dev/null +++ b/.changeset/public-things-stare.md @@ -0,0 +1,5 @@ +--- +'mermaid': major +--- + +Added support for the click directive in stateDiagram syntax diff --git a/packages/mermaid/src/diagrams/state/stateDiagram-v2.spec.js b/packages/mermaid/src/diagrams/state/stateDiagram-v2.spec.js index a79e44d5d..0df17e53a 100644 --- a/packages/mermaid/src/diagrams/state/stateDiagram-v2.spec.js +++ b/packages/mermaid/src/diagrams/state/stateDiagram-v2.spec.js @@ -442,5 +442,22 @@ describe('state diagram V2, ', function () { const currentDirection = stateDb.getDirection(); expect(currentDirection).toEqual('LR'); }); + it('should parse and store clickable link with tooltip using the click directive', () => { + const diagram = ` + stateDiagram-v2 + [*] --> StateA + click StateA "https://example.com" "Go to Example" + `; + + parser.parse(diagram); + + const links = stateDb.getLinks(); + + expect(links.has('StateA')).toBe(true); + + const linkInfo = links.get('StateA'); + expect(linkInfo.url).toBe('https://example.com'); + expect(linkInfo.tooltip).toBe('Go to Example'); + }); }); });