feat: register Iconify icon packs so diagram icons render - #2017
Open
dariodd wants to merge 1 commit into
Open
Conversation
mermaid ships no icons beyond architecture-beta's five built-ins. Everything else — `logos:aws`, `mdi:database`, an `icon:` on a flowchart node — resolves against packs the host registers, and the Live Editor registers none, so every such icon renders as mermaid's "?" placeholder. That includes the examples in the icon documentation itself. Register eight common packs with CDN loaders, as https://mermaid.js.org/config/icons.html describes. mermaid calls a loader only when a diagram names that pack, so nothing is downloaded until an icon is actually used, and a failed fetch falls back to today's placeholder.
✅ Deploy Preview for mermaidjs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
The problem
mermaid ships no icons beyond
architecture-beta's five built-ins (cloud,database,disk,internet,server). Every other icon —logos:aws,mdi:database, anicon:on a flowchart node — is resolved against packs the host registers, and the Live Editor registers none.So today, in the Live Editor:
brenders.arenders as mermaid's blue "?" placeholder — as does every icon in the icon documentation's own examples, and every icon in a diagram brought here from a tool that does register packs.The change
Register eight common Iconify packs with CDN loaders, exactly as the documentation describes:
logos,simple-icons,mdi,fa6-solid,fa6-brands,carbon,tabler,devicon.Cost
Nothing until an icon is used. mermaid calls a loader only when a diagram names that pack, and caches the result — so a session that draws no icons makes no request, and one that uses
logos:fetcheslogosalone. Nothing is added to the bundle and there is no new dependency.If a fetch fails — offline, or a self-hosted instance with no outbound access — mermaid falls back to the same "?" placeholder shown today. Nothing regresses.
Alternatives considered
@iconify-json/*as dependencies withimport()loaders) keeps it offline, butmdialone is 3.1 MB and the eight together are far more; a CDN fetch on demand seemed the better trade for a hosted editor. Happy to switch if you would rather not depend on unpkg.Tests
Not included on purpose: the only meaningful assertion is "an icon rendered", which needs a real network fetch and would make CI flaky. Happy to add a Playwright test behind a mock if you would like one.