refactor(treeView): replace bundled icons with iconify-based icon support#7840
Open
sidharthv96 wants to merge 8 commits into
Open
refactor(treeView): replace bundled icons with iconify-based icon support#7840sidharthv96 wants to merge 8 commits into
sidharthv96 wants to merge 8 commits into
Conversation
…port Removes all Apache-2.0-licensed Material Design icon paths and the filename/extension auto-detection tables. The diagram now ships a built-in iconify pack (prefix mermaid-treeview) containing only two originally drawn file and folder icons, used as defaults by node type. The icon() override now takes iconify references (icon(pack:name)) resolved through the shared registerIconPacks/getIconSVG pipeline, matching how architecture and flowchart icon shapes consume icons. icon()/icon(none) still hide a node's icon. Used icons are still injected once into <defs> (fetched in parallel) and referenced per row via <use>. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
| Name | Type |
|---|---|
| mermaid | Minor |
| @mermaid-js/parser | Minor |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/11.16.0 #7840 +/- ##
================================================
Coverage 64.35% 64.35%
================================================
Files 668 668
Lines 74754 74825 +71
Branches 11107 11129 +22
================================================
+ Hits 48107 48156 +49
- Misses 26647 26669 +22
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
SVG <text> collapses whitespace runs by default, so names like "But _ _ton💓.tsx" rendered with single spaces. Apply white-space: pre to label and description styles so labels render exactly as written. Bare labels now trim trailing whitespace in the value converter, since it would otherwise become visible (and affect width) with pre formatting. Adds a docs/demo example using emoji as filename icons together with showIcons: false. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
showIcons now defaults to false, so trees render as plain labels out of the box. When enabled, nodes get the built-in file/folder icons. Explicit icon() annotations always render regardless of showIcons; icon()/icon(none) hide a node's default icon. The parser no longer pre-fills default icons — it stores only explicit annotations, and the renderer resolves defaults via getNodeIcon() at draw time. Also adds the unicode-icons example to the examples package and keeps the whitespace stress-test name out of user-facing examples. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Restores automatic filename/extension-based icon detection, with the detected names aligned to the iconify devicon pack ids (typescript, react, python, html5, cplusplus, ...). Adds a defaultIconPack config option naming a registered iconify pack: auto-detected icons resolve in it, and unprefixed icon(name) references become shorthand for icon(pack:name). Built-in file/folder names always win, and files that detection misses keep the built-in file icon. Detection only runs when both showIcons and defaultIconPack are set, so plain trees stay the default. getNodeIcon now returns fully-qualified iconify references, removing the fallbackPrefix indirection in the renderer. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds filenameIcons and extensionIcons config options that extend or override the built-in detection maps. Values behave like icon() references — pack:name is used as-is, unprefixed names resolve via defaultIconPack (built-in file/folder names win), and none disables the icon for matching files. Filename matches (user, then built-in) beat extension matches; extension keys may omit the leading dot. sanitizeDirective previously deleted any config key not in configKeys, which stripped the arbitrary keys of these dictionary configs from frontmatter. Generalize the existing nodeColors special case into a table of dictionary configs whose values are pattern-validated instead (suspicious keys are still dropped), and add unit coverage for it. Also adds auto-detection and custom-mapping examples to the examples package. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Switches the auto-detected icon names from devicon ids to iconify vscode-icons ids (file-type-typescript, file-type-reactts, ...), which is a purpose-built file-icon collection: .tsx and .jsx now get distinct icons, and tsconfig.json maps to its own file-type-tsconfig icon. All names verified against the live collection. defaultIconPack examples, docs, demo page, examples package, the docs site pack registration, and the static e2e stand-in pack are updated accordingly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Removes the built-in filename/extension → icon tables. File-type icons are now fully user-configured: filenameIcons and extensionIcons map filenames/extensions to icons from registered packs, defaultIconPack resolves unprefixed references, and icon() overrides are unchanged. Without configured maps, files and directories get only the built-in file/folder icons (when showIcons is enabled). Mermaid no longer has an opinion on which icon a given file type should use, so there is no mapping to maintain and no pack-naming alignment to track. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Switches the example icon pack from vscode-icons to material-icon-theme across docs, demo page, examples package, e2e specs, and the static test pack — its icon ids are cleaner (docker, typescript, react-ts vs file-type-*). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reworks treeView-beta icons from bundled SVG paths to the shared iconify pipeline used by other diagrams (architecture, flowchart icon shapes), removing all Apache-2.0-licensed icon assets in the process.
mermaid-treeview) containing just two originally drawn icons —fileandfolder— themed viacurrentColor/iconColorregisterIconPacks/getIconSVG, exactly like the architecture diagramIcon resolution
For each node, the icon is resolved in this order:
icon(none)/icon()→ no iconicon(pack:name)→ used as-is;icon(name)→ built-infile/folder, else qualified withdefaultIconPack. Explicit icons always render, even withshowIconsoffshowIcons: true→ files are matched against the user-configuredfilenameIcons(exact name) andextensionIcons(last extension, case-insensitive, dot optional) maps; map values resolve likeicon()references, withnonehiding the iconfolder(directories) /file(files); withshowIcons: false(the default), no iconUnknown icon references render the standard unknown-icon ("?") fallback.
New config options
showIconsfalsedefaultIconPack''filenameIcons{}Dockerfile: docker)extensionIcons{}.ts: typescript);nonehides the icon for a matchNote
For now, icon packs (including the one named by
defaultIconPack) must be registered by the embedding site viaregisterIconPacks. Once #7113 lands, icon packs will also be addable via config, making the icon options usable without any JS setup.Implementation notes
ICON_ANNOTATIONterminal accepts an optionalpack:prefix (Langium regenerated)<defs>, with rows referencing it via<use>— no repeated icon markup per row. All resolution lives in onegetNodeIcon()helper shared by defs injection and row renderingsanitizeDirectivedeleted any key not inconfigKeys, which stripped the arbitrary keys offilenameIcons/extensionIconsfrom frontmatter. The existingnodeColorsspecial case was generalized into a dictionary-config table whose values are pattern-validated instead (suspicious keys still dropped), with new unit coverage pinning both behaviorswhite-space: pre), preserving consecutive spaces and emoji (handy as inline icons since trees are plain by default); bare labels trim trailing whitespaceiconId→iconto match other diagramslogosandmaterial-icon-themepacks so examples renderVerification
sanitizeDirectivespec; typecheck and lint cleanmaterial-icon-themestand-in pack,defaultIconPackshorthand, explicit iconify override (fa:bellstatic pack), unknown-icon fallback,icon(none)/icon()hiding, consecutive-space/unicode labels, and emoji-as-icons.tsx/.ts/Dockerfileicons,nonesuppression, built-in fallback for unmapped files, frontmatter config path, and the<defs>/<use>dedup structureshowIcons: false).🤖 Generated with Claude Code