Skip to content

feature/2645: add TreeView Diagram #7396

Merged
lee-treehouse merged 51 commits into
mermaid-js:developfrom
lee-treehouse:2645_add_tree_view_diagram_update
Mar 13, 2026
Merged

feature/2645: add TreeView Diagram #7396
lee-treehouse merged 51 commits into
mermaid-js:developfrom
lee-treehouse:2645_add_tree_view_diagram_update

Conversation

@lee-treehouse
Copy link
Copy Markdown
Collaborator

@lee-treehouse lee-treehouse commented Feb 16, 2026

📑 Summary

This 2024 PR #5665 introduced TreeView diagram and went through a thorough review process including updates to use Langium parser, docs, tests etc. The new diagram addressed issue #2645

That PR was almost merge ready. This PR branches off the original PR and addresses the following:

  • add tests for langium parser
  • parser bug impacting the ability to add title and accessibility title & description
  • add example to examples package
  • update development demos page to modern formatting (like https://github.com/mermaid-js/mermaid/blob/develop/demos/treemap.html)
  • address merge conflicts
  • address first round feedback
    • support for spaces in input
    • support to customize label colour (as well as existing customisations for label font size and line colour)
    • correct changeset

I am happy to address any other changes required (or reinvolve @Vikrantpalle)

CleanShot 2026-03-07 at 15 35 20@2x CleanShot 2026-03-07 at 15 53 19@2x

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added necessary unit/e2e tests.
  • 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
  • 🦋 If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Vikrantpalle and others added 13 commits July 26, 2024 00:39
…add_tree_view_diagram_update

# Conflicts:
#	.build/jsonSchema.ts
#	demos/index.html
#	docs/config/setup/interfaces/mermaid.MermaidConfig.md
#	docs/config/setup/modules/defaultConfig.md
#	packages/mermaid/src/config.type.ts
#	packages/mermaid/src/defaultConfig.ts
#	packages/mermaid/src/diagram-api/diagram-orchestration.ts
#	packages/mermaid/src/docs/.vitepress/config.ts
#	packages/mermaid/src/mermaidAPI.spec.ts
#	packages/mermaid/src/schemas/config.schema.yaml
#	packages/mermaid/src/styles.spec.ts
#	packages/parser/langium-config.json
#	packages/parser/src/language/index.ts
#	packages/parser/src/parse.ts
@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 16, 2026

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit cba0761
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/69b335be542e850008ab18ed
😎 Deploy Preview https://deploy-preview-7396--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 16, 2026

🦋 Changeset detected

Latest commit: cba0761

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@mermaid-js/examples Minor
mermaid Minor
@mermaid-js/parser Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 16, 2026

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/@mermaid-js/examples@7396

mermaid

npm i https://pkg.pr.new/mermaid@7396

@mermaid-js/layout-elk

npm i https://pkg.pr.new/@mermaid-js/layout-elk@7396

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/@mermaid-js/layout-tidy-tree@7396

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/@mermaid-js/mermaid-zenuml@7396

@mermaid-js/parser

npm i https://pkg.pr.new/@mermaid-js/parser@7396

@mermaid-js/tiny

npm i https://pkg.pr.new/@mermaid-js/tiny@7396

commit: 12f192b

@argos-ci
Copy link
Copy Markdown

argos-ci Bot commented Feb 16, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 4 added Mar 12, 2026, 10:02 PM

@lee-treehouse
Copy link
Copy Markdown
Collaborator Author

lee-treehouse commented Feb 16, 2026

There is a unit test failure relating to accessibility that I am investigating
Passing accTitle: and accDescr: are not understood to be keywords and instead incorporated in the diagram, so they fail these assertions
CleanShot 2026-02-16 at 13 36 46@2x

We would expect those accessibility keywords to result in nodes added to the svg as per this example:

CleanShot 2026-02-16 at 13 28 04@2x

This is a issue with the grammar, easier to understand the behaviour from the langium playground. You can observe that all the words in the title, accessible title and description become nodes for the tree diagram.
I will find out what is needed to fix it.
CleanShot 2026-02-17 at 09 45 43@2x

Update: fixed, but I found the whitespace / indent handling to be very fragile. Seems we observed this with treemap already and updating to langium v4
CleanShot 2026-02-17 at 14 03 37@2x

@jasonkolodziej
Copy link
Copy Markdown

…add_tree_view_diagram_update

# Conflicts:
#	packages/mermaid/src/docs/.vitepress/config.ts
@lee-treehouse
Copy link
Copy Markdown
Collaborator Author

@knsv all blocking feedback and fresh merge conflicts addressed, I'm hoping this one is good to go after a few contributors trying to finish it off the last couple of years 🤞

Copy link
Copy Markdown
Collaborator

@knsv knsv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great Work!

All three blocking issues are resolved:

  • ✅ Parser test file now included — packages/parser/tests/treeView.test.ts is in the PR with 7 test cases, including the new multi-word test ("Multi Word Root"). Well done.
  • ✅ Changeset is now minor — .changeset/weak-tools-pay.md correctly bumps all three packages as minor.
  • ✅ Multi-word node names — The grammar was redesigned to use quoted strings (STRING2: /"[^"]"|'[^']'/), with the valueConverter stripping quotes. This is a clean solution. The demo no longer has broken node
    names.

Also fixed:

  • ✅ Cypress tests now have 4 cases including a custom config test that exercises labelColor, lineColor, and rowIndent. Nice addition. 🎉

@knsv knsv added this pull request to the merge queue Mar 12, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 12, 2026
@knsv knsv added this pull request to the merge queue Mar 12, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 12, 2026
@lee-treehouse
Copy link
Copy Markdown
Collaborator Author

The PR was removed from the merge queue due to a unit test failure. The cause is a new unit test that was merged earlier today via #7410. I've pushed a commit to make the new test aware of this new diagram and the unit tests are now passing, ready for another stab at the merge queue if possible @knsv 🙏

@lee-treehouse lee-treehouse added this pull request to the merge queue Mar 13, 2026
Merged via the queue into mermaid-js:develop with commit b681756 Mar 13, 2026
21 of 22 checks passed
@lee-treehouse lee-treehouse deleted the 2645_add_tree_view_diagram_update branch March 13, 2026 21:14
notionparallax added a commit to notionparallax/mermaid that referenced this pull request Mar 25, 2026
…tions, highlights

Extends treeView-beta (PR mermaid-js#7396 by @lee-treehouse and @Vikrantpalle) with
file-tree-specific features:

- Bare (unquoted) labels: src/, index.js, .gitignore
- 30+ auto-detected file-type icons (JS, TS, Python, Docker, etc.)
- :::class annotations (e.g. :::highlight for yellow background)
- icon(name) overrides for custom icons
- ## inline descriptions, column-aligned across all nodes
- Directory auto-detection via trailing slash
- Folder names with spaces (unquoted)
- Two-pass rendering for description column alignment
- Diagram-scoped icon symbol IDs (no duplicates on multi-diagram pages)
- Side-by-side demo page showing input syntax next to rendered output
- 26 new parseNodeContent unit tests + 8 new Langium parser tests
- 5 new Cypress E2E tests
- Comprehensive docs rewrite with all new features

Grammar: NODE_CONTENT terminal captures rest-of-line; detailed annotation
parsing (:::class, icon(), ##) delegated to TypeScript parseNodeContent().

Closes mermaid-js#7516
@D1no
Copy link
Copy Markdown

D1no commented Apr 20, 2026

Its probably too late, but one of the most use cases for a tree file view in ascii is to add comments or descriptions behind the file - folder. AI uses that extensively like below.

Was searching if mermaid could do that natively and landed here.

.
├── readme.md                          ← you are here: top-level index
├── CLAUDE.md                          ← Claude Code session bootstrap + hard rules
├── Taskfile.yml                       ← root task runner: `task --list`
├── lefthook.yml                       ← declarative git-hook manager
├── docs/                              ← per-model state-of-play + convention indexes
│   ├── gemma4.md                        (overview + HANDOFF + full matrix + phases)
│   ├── qwen36.md                        (early; research-only until first scout lands)
│   ├── conventions.md                   (human-readable index of .claude/memory rules)
│   ├── handoff-procedure.md             (end-of-session handoff ritual + next-session bootstrap)
│   └── fresh-eyes-review-2026-04-20.md  (dated navigation review, Tier A/B/C findings)
├── scripts/                           ← repo-wide helpers (DX + Modal log analysis)
...

@pbrolin47
Copy link
Copy Markdown
Collaborator

@D1no Thanks for the suggestion!
May I ask you to create an issue labeled Type: Enhancement targeting TreeView diagrams. Maybe someone in the community will pick-up the proposed enhancement

@D1no
Copy link
Copy Markdown

D1no commented Apr 21, 2026

👍 will do

@D1no
Copy link
Copy Markdown

D1no commented Apr 21, 2026

@pbrolin47 done
#7640 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants