Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initialize of theme arguments works in version < 10, but not after #4672

Closed
fralau opened this issue Jul 26, 2023 · 6 comments
Closed

initialize of theme arguments works in version < 10, but not after #4672

fralau opened this issue Jul 26, 2023 · 6 comments
Labels
Type: Bug / Error Something isn't working or is incorrect

Comments

@fralau
Copy link

fralau commented Jul 26, 2023

Description

In version 10, the following sequence does not alter the theme:

<script type="module">import mermaid from "https://unpkg.com/mermaid@10.2.0/dist/mermaid.esm.min.mjs"</script>
<script>mermaidAPI.initialize({
    theme: "base",
    themeVariables: {
        primaryColor: "#BB2528",
        primaryTextColor: "#fff",
        primaryBorderColor: "#7C0000",
        lineColor: "#F8B229",
        secondaryColor: "#006100",
        tertiaryColor: "#fff"
    }
});</script>

(Does not work with mermaid.initialize() either).

But works in version 9 (colors are properly changed):

<script src="[https://unpkg.com/mermaid@9.2.0/dist/mermaid.min.js](view-source:https://unpkg.com/mermaid@9.2.0/dist/mermaid.min.js)"></script><script>mermaid.initialize({
    theme: "base",
    themeVariables: {
        primaryColor: "#BB2528",
        primaryTextColor: "#fff",
        primaryBorderColor: "#7C0000",
        lineColor: "#F8B229",
        secondaryColor: "#006100",
        tertiaryColor: "#fff"
    }
});</script>

Steps to reproduce

Try a diagram in version 9 and 10.

Screenshots

Version 9:

Capture d’écran 2023-07-26 à 16 07 20

Version 10:
Capture d’écran 2023-07-26 à 16 07 58

Code Sample

Use with e.g. this diagram:

 graph LR
    hello --> world
    world --> again
    again --> hello
graph LR
    hello --> world
    world --> again
    again --> hello
<div class="mermaid">graph LR
    hello --&gt; world
    world --&gt; again
    again --&gt; hello
</div>

Setup

  • Mermaid version: 9.2.0 and 10.2.0
  • Browser and Version: Firefox, Safari (Mac)

Suggested Solutions

No response

Additional Context

No response

@fralau fralau added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Jul 26, 2023
@sidharthv96 sidharthv96 removed the Status: Triage Needs to be verified, categorized, etc label Aug 8, 2023
@sidharthv96
Copy link
Member

Please use mermaid.initialize, not mermiadAPI.initialize.

mermaid.initialize({
        theme: 'base',
        themeVariables: {
          primaryColor: '#BB2528',
          primaryTextColor: '#fff',
          primaryBorderColor: '#7C0000',
          lineColor: '#F8B229',
          secondaryColor: '#006100',
          tertiaryColor: '#fff',
        }
      });
image

@fralau
Copy link
Author

fralau commented Aug 8, 2023

As indicated, I did use mermaid.initialize() and it did not work.

@sidharthv96
Copy link
Member

That was because you were using 2 separate script tags.

<script type="module">import mermaid from "https://unpkg.com/mermaid@10.2.0/dist/mermaid.esm.min.mjs"</script>
<script>mermaidAPI.initialize({

Removing the second script tag fixes the issue.

image

<div class="mermaid">
  graph LR
    hello --> world
    world --> again
    again --> hello
</div>

<script type="module">
import mermaid from "https://unpkg.com/mermaid@10.2.0/dist/mermaid.esm.min.mjs";
mermaid.initialize({
    theme: "base",
    themeVariables: {
        primaryColor: "#BB2528",
        primaryTextColor: "#fff",
        primaryBorderColor: "#7C0000",
        lineColor: "#F8B229",
        secondaryColor: "#006100",
        tertiaryColor: "#fff"
    }
});
</script>

@sidharthv96
Copy link
Member

Please close this if it was resolved.

@fralau
Copy link
Author

fralau commented Aug 9, 2023

Interesting! Let me check.

@fralau
Copy link
Author

fralau commented Aug 9, 2023

This worked, thanks! mkdocs-mermaid2 was fixed and it worked.

See fralau/mkdocs-mermaid2-plugin#82

🚀

@fralau fralau closed this as completed Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests

2 participants