mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 03:29:02 +01:00 
			
		
		
		
	fixes
This commit is contained in:
		
							parent
							
								
									8a8bdaf80e
								
							
						
					
					
						commit
						a68fd5ab83
					
				| @ -6,6 +6,8 @@ import libraryLoader from "./library_loader.js"; | ||||
| import openService from "./open.js"; | ||||
| import froca from "./froca.js"; | ||||
| 
 | ||||
| let idCounter = 1; | ||||
| 
 | ||||
| async function getRenderedContent(note, options = {}) { | ||||
|     options = Object.assign({ | ||||
|         trim: false, | ||||
| @ -93,7 +95,7 @@ async function getRenderedContent(note, options = {}) { | ||||
|             .css("justify-content", "space-around"); | ||||
| 
 | ||||
|         try { | ||||
|             mermaid.mermaidAPI.render("mermaid-graph", content, | ||||
|             mermaid.mermaidAPI.render("in-mermaid-graph-" + idCounter++, content, | ||||
|                     content => $renderedContent.append($(content))); | ||||
|         } catch (e) { | ||||
|             const $error = $("<p>The diagram could not displayed.</p>"); | ||||
|  | ||||
| @ -35,6 +35,10 @@ const TPL = ` | ||||
| </div>`; | ||||
| 
 | ||||
| export default class NoteActionsWidget extends NoteContextAwareWidget { | ||||
|     isEnabled() { | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     doRender() { | ||||
|         this.$widget = $(TPL); | ||||
| 
 | ||||
|  | ||||
| @ -18,20 +18,16 @@ const TPL = `<div class="mermaid-widget"> | ||||
|     </style> | ||||
| 
 | ||||
|     <div class="mermaid-error alert alert-warning"> | ||||
|         <p><strong>The diagram could not displayed.</strong></p> | ||||
|         <p class="error-content">Rendering diagram...</p> | ||||
|         <p><strong>The diagram could not displayed. See <a href="https://mermaid-js.github.io/mermaid/#/flowchart?id=graph">help and examples</a>.</strong></p> | ||||
|         <p class="error-content"></p> | ||||
|     </div> | ||||
| 
 | ||||
|     <div class="mermaid-render"></div> | ||||
| </div>`; | ||||
| 
 | ||||
| let idCounter = 1; | ||||
| 
 | ||||
| export default class MermaidWidget extends NoteContextAwareWidget { | ||||
|     constructor() { | ||||
|         super(); | ||||
| 
 | ||||
|         this.idCounter = 1; | ||||
|     } | ||||
| 
 | ||||
|     isEnabled() { | ||||
|         return super.isEnabled() && this.note && this.note.type === 'mermaid'; | ||||
|     } | ||||
| @ -45,6 +41,8 @@ export default class MermaidWidget extends NoteContextAwareWidget { | ||||
|     } | ||||
| 
 | ||||
|     async refreshWithNote(note) { | ||||
|         this.$errorContainer.hide(); | ||||
| 
 | ||||
|         await libraryLoader.requireLibrary(libraryLoader.MERMAID); | ||||
| 
 | ||||
|         const documentStyle = window.getComputedStyle(document.documentElement); | ||||
| @ -57,14 +55,12 @@ export default class MermaidWidget extends NoteContextAwareWidget { | ||||
| 
 | ||||
|         this.$display.empty(); | ||||
| 
 | ||||
|         this.$errorMessage.text('Rendering diagram...'); | ||||
| 
 | ||||
|         try { | ||||
|             mermaid.mermaidAPI.render('graphDiv-' + this.idCounter++, content, content => this.$display.html(content)); | ||||
|             mermaid.mermaidAPI.render('mermaid-graph-' + idCounter++, content, content => this.$display.html(content)); | ||||
| 
 | ||||
|             this.$errorContainer.hide(); | ||||
|         } catch (e) { | ||||
|             this.$errorMessage.text(e.message).append(`<br/><br/><p>See <a href="https://mermaid-js.github.io/mermaid/#/flowchart?id=graph">help and examples</a>.</p>`); | ||||
|             this.$errorMessage.text(e.message); | ||||
|             this.$errorContainer.show(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -624,7 +624,8 @@ class ConsistencyChecks { | ||||
| 
 | ||||
|             ws.sendMessageToAllClients({type: 'consistency-checks-failed'}); | ||||
|         } else { | ||||
|             log.info(`All consistency checks passed (took ${elapsedTimeMs}ms)`); | ||||
|             log.info(`All consistency checks passed (took ${elapsedTimeMs}ms)` + | ||||
|                 (this.fixedIssues ? " after some fixes" : "with no errors detected")); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam