@@ -9,8 +9,6 @@ import DomAccess from '../DomAccess.mjs';
99 *
1010 * Key features:
1111 * - **Lazy Loading:** Dynamically loads the Mermaid library only when needed.
12- * - **Theme Mapping:** Automatically translates Neo.mjs application themes (e.g., 'neo-theme-dark') to Mermaid's internal themes.
13- * - **Dynamic Re-rendering:** Handles theme switches at runtime by re-initializing the library.
1412 * - **SVG Generation:** Uses `mermaid.render()` to generate idempotent SVG output, ensuring reliable DOM updates.
1513 *
1614 * It is primarily consumed by:
@@ -22,20 +20,6 @@ import DomAccess from '../DomAccess.mjs';
2220 * @see Neo.component.wrapper.Mermaid
2321 */
2422class Mermaid extends Base {
25- /**
26- * Maps Neo.mjs theme names to Mermaid.js theme names.
27- * This allows the addon to automatically select the most appropriate visual style
28- * based on the current application theme.
29- * @member {Object} themeMap
30- */
31- static themeMap = {
32- 'neo-theme-cyberpunk' : 'dark' ,
33- 'neo-theme-dark' : 'dark' ,
34- 'neo-theme-light' : 'default' ,
35- 'neo-theme-neo-dark' : 'dark' ,
36- 'neo-theme-neo-light' : 'default'
37- }
38-
3923 static config = {
4024 /**
4125 * @member {String} className='Neo.main.addon.Mermaid'
@@ -70,12 +54,6 @@ class Mermaid extends Base {
7054 useLazyLoading : true
7155 }
7256
73- /**
74- * Tracks the currently active Mermaid theme to prevent redundant re-initialization.
75- * @member {String} currentTheme='default'
76- */
77- currentTheme = 'default'
78-
7957 /**
8058 * Loads the Mermaid library if it is not already present.
8159 * Initializes the library with `startOnLoad: false` to allow manual control over rendering.
@@ -92,32 +70,20 @@ class Mermaid extends Base {
9270 * Renders a Mermaid diagram into a specific DOM element.
9371 *
9472 * This method orchestrates the full rendering pipeline:
95- * 1. **Theme Resolution:** Maps the requested Neo theme to a Mermaid theme.
96- * 2. **Re-initialization:** If the theme has changed, it re-configures Mermaid globally.
97- * 3. **SVG Generation:** Generates a fresh SVG string for the diagram code.
98- * 4. **DOM Injection:** Safely injects the SVG into the target container.
73+ * 1. **SVG Generation:** Generates a fresh SVG string for the diagram code.
74+ * 2. **DOM Injection:** Safely injects the SVG into the target container.
9975 *
10076 * It includes error handling to display rendering failures inline (e.g., syntax errors)
10177 * instead of crashing the application.
10278 *
10379 * @param {Object } data
10480 * @param {String } [data.code] The mermaid diagram syntax/code.
10581 * @param {String } data.id The DOM ID of the container element.
106- * @param {String } [data.theme] The neo theme to use (e.g. 'neo-theme-dark').
10782 */
10883 async render ( data ) {
109- const
110- element = document . getElementById ( data . id ) ,
111- me = this ;
84+ const element = document . getElementById ( data . id ) ;
11285
11386 if ( element ) {
114- const theme = me . getStaticConfig ( 'themeMap' ) [ data . theme ] || 'default' ;
115-
116- if ( me . currentTheme !== theme ) {
117- me . currentTheme = theme ;
118- mermaid . initialize ( { startOnLoad : false , theme} )
119- }
120-
12187 try {
12288 const { svg} = await mermaid . render ( data . id + '__svg' , data . code ) ;
12389 element . innerHTML = svg
0 commit comments