@@ -18,11 +18,10 @@ import { useEffect, useState } from 'react';
18
18
import { PaletteType , useTheme } from '@material-ui/core' ;
19
19
20
20
import { useShadowRootElements } from '@backstage/plugin-techdocs-react' ;
21
- import mermaid from 'mermaid'
21
+ import mermaid , { MermaidConfig } from 'mermaid'
22
22
import { isMermaidCode } from './hooks' ;
23
23
import { MermaidProps } from './props' ;
24
24
import { BackstageTheme } from '@backstage/theme' ;
25
- import { MermaidConfig } from 'mermaid' ;
26
25
27
26
export function selectConfig ( backstagePalette : PaletteType , properties : MermaidProps ) : MermaidConfig {
28
27
// Theme set directly in the Mermaid configuration takes
@@ -63,7 +62,6 @@ export const MermaidAddon = (properties: MermaidProps) => {
63
62
const highlightDivs = useShadowRootElements < HTMLDivElement > ( [ '.highlight' ] ) ;
64
63
const mermaidPreBlocks = useShadowRootElements < HTMLPreElement > ( [ '.mermaid' ] ) ;
65
64
const theme = useTheme < BackstageTheme > ( ) ;
66
-
67
65
68
66
const [ initialized , setInitialized ] = useState ( false ) ;
69
67
@@ -72,6 +70,9 @@ export const MermaidAddon = (properties: MermaidProps) => {
72
70
return ;
73
71
}
74
72
const config = selectConfig ( theme . palette . type , properties ) ;
73
+ if ( properties . iconLoaders ) {
74
+ mermaid . registerIconPacks ( properties . iconLoaders ) ;
75
+ }
75
76
mermaid . initialize ( config ) ;
76
77
setInitialized ( true ) ;
77
78
} , [ initialized ] ) ;
0 commit comments