mirror of
				https://github.com/mermaid-js/mermaid.git
				synced 2025-11-03 20:34:20 +01:00 
			
		
		
		
	Made mermaidConfig a local variable so that it cannot be shared cross rendering.
This commit is contained in:
		@@ -20,11 +20,6 @@ const props = defineProps({
 | 
			
		||||
const svg = ref(null);
 | 
			
		||||
let mut = null;
 | 
			
		||||
 | 
			
		||||
const mermaidConfig = {
 | 
			
		||||
  securityLevel: 'loose',
 | 
			
		||||
  startOnLoad: false,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
onMounted(async () => {
 | 
			
		||||
  mut = new MutationObserver(() => renderChart());
 | 
			
		||||
  mut.observe(document.documentElement, { attributes: true });
 | 
			
		||||
@@ -58,7 +53,11 @@ onUnmounted(() => mut.disconnect());
 | 
			
		||||
const renderChart = async () => {
 | 
			
		||||
  console.log('rendering chart' + props.id + props.graph);
 | 
			
		||||
  const hasDarkClass = document.documentElement.classList.contains('dark');
 | 
			
		||||
  mermaidConfig.theme = hasDarkClass ? 'dark' : 'default';
 | 
			
		||||
  const mermaidConfig = {
 | 
			
		||||
        securityLevel: 'loose',
 | 
			
		||||
        startOnLoad: false,
 | 
			
		||||
        theme: hasDarkClass ? 'dark' : 'default',
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
  console.log({ mermaidConfig });
 | 
			
		||||
  let svgCode = await render(props.id, decodeURIComponent(props.graph), mermaidConfig);
 | 
			
		||||
 
 | 
			
		||||
@@ -8,9 +8,7 @@ try {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const render = async (id: string, code: string, config: MermaidConfig): Promise<string> => {
 | 
			
		||||
  // make a clone of config, so we don't mutate the original
 | 
			
		||||
  const mermaidConfig = { ...config };
 | 
			
		||||
  mermaid.initialize(mermaidConfig);
 | 
			
		||||
  mermaid.initialize(config);
 | 
			
		||||
  const svg = await mermaid.renderAsync(id, code);
 | 
			
		||||
  return svg;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user