mirror of
				https://github.com/mermaid-js/mermaid.git
				synced 2025-11-04 12:54:08 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			163 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			163 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<html>
 | 
						|
  <head>
 | 
						|
    <link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet" />
 | 
						|
    <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet" />
 | 
						|
    <link
 | 
						|
      rel="stylesheet"
 | 
						|
      href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
 | 
						|
    />
 | 
						|
    <link
 | 
						|
      href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css"
 | 
						|
      rel="stylesheet"
 | 
						|
    />
 | 
						|
    <link
 | 
						|
      href="https://fonts.googleapis.com/css?family=Noto+Sans+SC&display=swap"
 | 
						|
      rel="stylesheet"
 | 
						|
    />
 | 
						|
    <link rel="preconnect" href="https://fonts.googleapis.com" />
 | 
						|
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
 | 
						|
    <link
 | 
						|
      href="https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&display=swap"
 | 
						|
      rel="stylesheet"
 | 
						|
    />
 | 
						|
    <link
 | 
						|
      href="https://fonts.googleapis.com/css2?family=Caveat:wght@400..700&family=Kalam:wght@300;400;700&family=Rubik+Mono+One&display=swap"
 | 
						|
      rel="stylesheet"
 | 
						|
    />
 | 
						|
    <link
 | 
						|
      href="https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&family=Rubik+Mono+One&display=swap"
 | 
						|
      rel="stylesheet"
 | 
						|
    />
 | 
						|
 | 
						|
    <style>
 | 
						|
      body {
 | 
						|
        /* background: rgb(221, 208, 208); */
 | 
						|
        /* background: #333; */
 | 
						|
        font-family: 'Arial';
 | 
						|
        /* font-size: 18px !important; */
 | 
						|
      }
 | 
						|
      h1 {
 | 
						|
        color: grey;
 | 
						|
      }
 | 
						|
      .mermaid2 {
 | 
						|
        display: none;
 | 
						|
      }
 | 
						|
      .mermaid svg {
 | 
						|
        /* font-size: 18px !important; */
 | 
						|
 | 
						|
        /* background-color: #efefef;
 | 
						|
        background-image: radial-gradient(#fff 51%, transparent 91%),
 | 
						|
          radial-gradient(#fff 51%, transparent 91%);
 | 
						|
        background-size: 20px 20px;
 | 
						|
        background-position:
 | 
						|
          0 0,
 | 
						|
          10px 10px;
 | 
						|
        background-repeat: repeat; */
 | 
						|
      }
 | 
						|
      .malware {
 | 
						|
        position: fixed;
 | 
						|
        bottom: 0;
 | 
						|
        left: 0;
 | 
						|
        right: 0;
 | 
						|
        height: 150px;
 | 
						|
        background: red;
 | 
						|
        color: black;
 | 
						|
        display: flex;
 | 
						|
        display: flex;
 | 
						|
        justify-content: center;
 | 
						|
        align-items: center;
 | 
						|
        font-family: monospace;
 | 
						|
        font-size: 72px;
 | 
						|
      }
 | 
						|
      /* tspan {
 | 
						|
              font-size: 6px !important;
 | 
						|
            } */
 | 
						|
    </style>
 | 
						|
  </head>
 | 
						|
  <body>
 | 
						|
    <pre id="diagram" class="mermaid"></pre>
 | 
						|
 | 
						|
    <script type="module">
 | 
						|
      import mermaid from './mermaid.esm.mjs';
 | 
						|
      import { layouts } from './mermaid-layout-elk.esm.mjs';
 | 
						|
      mermaid.registerLayoutLoaders(layouts);
 | 
						|
      mermaid.parseError = function (err, hash) {
 | 
						|
        console.error('Mermaid error: ', err);
 | 
						|
      };
 | 
						|
      mermaid.initialize({
 | 
						|
        startOnLoad: false,
 | 
						|
        // look: 'handdrawn',
 | 
						|
        layout: 'fixed',
 | 
						|
        fontFamily: 'Kalam',
 | 
						|
        sequence: {
 | 
						|
          actorFontFamily: 'courier',
 | 
						|
          noteFontFamily: 'courier',
 | 
						|
          messageFontFamily: 'courier',
 | 
						|
        },
 | 
						|
        logLevel: 0,
 | 
						|
      });
 | 
						|
      mermaid.parseError = function (err, hash) {
 | 
						|
        console.error('In parse error:');
 | 
						|
        console.error(err);
 | 
						|
      };
 | 
						|
      let code = `
 | 
						|
stateDiagram
 | 
						|
  S:Stillas
 | 
						|
  T:Tiger
 | 
						|
  U:Ulv
 | 
						|
  state Z {
 | 
						|
    state X {
 | 
						|
      Y:Ypsilon
 | 
						|
    }
 | 
						|
  }
 | 
						|
  A
 | 
						|
 | 
						|
  S --> T: angrepp
 | 
						|
  T --> U: Apa
 | 
						|
  T --> V: Varg
 | 
						|
        `;
 | 
						|
 | 
						|
      const positions = {
 | 
						|
        nodes: {
 | 
						|
          S: { x: 0, y: 0 },
 | 
						|
          T: { x: 100, y: 100, width: 100, height: 100 },
 | 
						|
          U: { x: 200, y: 200 },
 | 
						|
          V: { x: 300, y: 120 },
 | 
						|
          Z: { x: 300, y: 10, width: 160, height: 100 },
 | 
						|
          X: { x: 300, y: 20, width: 80, height: 60 },
 | 
						|
          Y: { x: 300, y: 30, width: 50, height: 20 },
 | 
						|
          A: { x: 300, y: 75, width: 20, height: 20 },
 | 
						|
        },
 | 
						|
        edges: {
 | 
						|
          edge0: {
 | 
						|
            points: [
 | 
						|
              { x: 0, y: 0 },
 | 
						|
              { x: 50, y: 0 },
 | 
						|
              { x: 100, y: 100 },
 | 
						|
            ],
 | 
						|
          },
 | 
						|
          edge1: {
 | 
						|
            points: [
 | 
						|
              { x: 100, y: 100 },
 | 
						|
              { x: 200, y: 200 },
 | 
						|
            ],
 | 
						|
          },
 | 
						|
          edge2: {
 | 
						|
            points: [
 | 
						|
              { x: 100, y: 100 },
 | 
						|
              { x: 175, y: 80 },
 | 
						|
              { x: 200, y: 120 },
 | 
						|
              { x: 300, y: 100 },
 | 
						|
            ],
 | 
						|
          },
 | 
						|
        },
 | 
						|
      };
 | 
						|
 | 
						|
      const { svg } = await mermaid.render('the-id-of-the-svg', code, undefined, positions);
 | 
						|
      // console.log(svg);
 | 
						|
      const elem = document.querySelector('#diagram');
 | 
						|
      elem.innerHTML = svg;
 | 
						|
    </script>
 | 
						|
  </body>
 | 
						|
</html>
 |