mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	feat(ck-mermaid): use default mermaid config
This commit is contained in:
		
							
								
								
									
										2
									
								
								libraries/ckeditor/ckeditor.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								libraries/ckeditor/ckeditor.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -59,21 +59,9 @@ export default class MermaidWidget extends NoteContextAwareWidget { | |||||||
|  |  | ||||||
|         await libraryLoader.requireLibrary(libraryLoader.MERMAID); |         await libraryLoader.requireLibrary(libraryLoader.MERMAID); | ||||||
|  |  | ||||||
|         const documentStyle = window.getComputedStyle(document.documentElement); |  | ||||||
|         const mermaidTheme = documentStyle.getPropertyValue('--mermaid-theme');         |  | ||||||
|          |  | ||||||
|         mermaid.mermaidAPI.initialize({ |         mermaid.mermaidAPI.initialize({ | ||||||
|             startOnLoad: false, |             startOnLoad: false, | ||||||
|             theme: mermaidTheme.trim(), |             ...getMermaidConfig() | ||||||
|             securityLevel: 'antiscript', |  | ||||||
|             flow: { useMaxWidth: false }, |  | ||||||
|             sequence: { useMaxWidth: false }, |  | ||||||
|             gantt: { useMaxWidth: false }, |  | ||||||
|             "class": { useMaxWidth: false }, |  | ||||||
|             state: { useMaxWidth: false }, |  | ||||||
|             pie: { useMaxWidth: true }, |  | ||||||
|             journey: { useMaxWidth: false }, |  | ||||||
|             git: { useMaxWidth: false }, |  | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         this.$display.empty(); |         this.$display.empty(); | ||||||
| @@ -146,3 +134,21 @@ export default class MermaidWidget extends NoteContextAwareWidget { | |||||||
|         utils.downloadSvg(this.note.title, svg); |         utils.downloadSvg(this.note.title, svg); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | export function getMermaidConfig() { | ||||||
|  |     const documentStyle = window.getComputedStyle(document.documentElement); | ||||||
|  |     const mermaidTheme = documentStyle.getPropertyValue('--mermaid-theme'); | ||||||
|  |  | ||||||
|  |     return { | ||||||
|  |         theme: mermaidTheme.trim(), | ||||||
|  |         securityLevel: 'antiscript', | ||||||
|  |         flow: { useMaxWidth: false }, | ||||||
|  |         sequence: { useMaxWidth: false }, | ||||||
|  |         gantt: { useMaxWidth: false }, | ||||||
|  |         "class": { useMaxWidth: false }, | ||||||
|  |         state: { useMaxWidth: false }, | ||||||
|  |         pie: { useMaxWidth: true }, | ||||||
|  |         journey: { useMaxWidth: false }, | ||||||
|  |         git: { useMaxWidth: false }, | ||||||
|  |     }; | ||||||
|  | } | ||||||
|   | |||||||
| @@ -13,6 +13,7 @@ import dialogService from "../../services/dialog.js"; | |||||||
| import { initSyntaxHighlighting } from "./ckeditor/syntax_highlight.js"; | import { initSyntaxHighlighting } from "./ckeditor/syntax_highlight.js"; | ||||||
| import options from "../../services/options.js"; | import options from "../../services/options.js"; | ||||||
| import toast from "../../services/toast.js"; | import toast from "../../services/toast.js"; | ||||||
|  | import { getMermaidConfig } from "../mermaid.js"; | ||||||
|  |  | ||||||
| const ENABLE_INSPECTOR = false; | const ENABLE_INSPECTOR = false; | ||||||
|  |  | ||||||
| @@ -259,7 +260,8 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget { | |||||||
|                 enablePreview: true // Enable preview view |                 enablePreview: true // Enable preview view | ||||||
|             }, |             }, | ||||||
|             mermaid: { |             mermaid: { | ||||||
|                 lazyLoad: async () => await libraryLoader.requireLibrary(libraryLoader.MERMAID) |                 lazyLoad: async () => await libraryLoader.requireLibrary(libraryLoader.MERMAID), | ||||||
|  |                 config: getMermaidConfig() | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user