mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	added zooming/panning to mermaid diagrams, closes #2635
This commit is contained in:
		
							parent
							
								
									b250f0a3bf
								
							
						
					
					
						commit
						f7d6bda49d
					
				
							
								
								
									
										2
									
								
								libraries/wheel-zoom.min.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								libraries/wheel-zoom.min.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -17,11 +17,12 @@ const TPL = `<div class="mermaid-widget">
 | 
				
			|||||||
        .mermaid-render {
 | 
					        .mermaid-render {
 | 
				
			||||||
            overflow: auto;
 | 
					            overflow: auto;
 | 
				
			||||||
            height: 100%;
 | 
					            height: 100%;
 | 
				
			||||||
 | 
					            text-align: center;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    </style>
 | 
					    </style>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <div class="mermaid-error alert alert-warning">
 | 
					    <div class="mermaid-error alert alert-warning">
 | 
				
			||||||
        <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><strong>The diagram could not be displayed. See <a href="https://mermaid-js.github.io/mermaid/#/flowchart?id=graph">help and examples</a>.</strong></p>
 | 
				
			||||||
        <p class="error-content"></p>
 | 
					        <p class="error-content"></p>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -70,8 +71,25 @@ export default class MermaidWidget extends NoteContextAwareWidget {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        this.$display.empty();
 | 
					        this.$display.empty();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const libLoaded = libraryLoader.requireLibrary(libraryLoader.WHEEL_ZOOM);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            mermaid.mermaidAPI.render('mermaid-graph-' + idCounter++, content, content => this.$display.html(content));
 | 
					            const idNumber = idCounter++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            mermaid.mermaidAPI.render('mermaid-graph-' + idNumber, content, async content => {
 | 
				
			||||||
 | 
					                this.$display.html(content);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                await libLoaded;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                this.$display.attr("id", 'mermaid-render-' + idNumber);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                WZoom.create('#mermaid-render-' + idNumber, {
 | 
				
			||||||
 | 
					                    type: 'html',
 | 
				
			||||||
 | 
					                    maxScale: 10,
 | 
				
			||||||
 | 
					                    speed: 20,
 | 
				
			||||||
 | 
					                    zoomOnClick: false
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            this.$errorContainer.hide();
 | 
					            this.$errorContainer.hide();
 | 
				
			||||||
        } catch (e) {
 | 
					        } catch (e) {
 | 
				
			||||||
 | 
				
			|||||||
@ -49,6 +49,7 @@ class ImageTypeWidget extends TypeWidget {
 | 
				
			|||||||
        libraryLoader.requireLibrary(libraryLoader.WHEEL_ZOOM).then(() => {
 | 
					        libraryLoader.requireLibrary(libraryLoader.WHEEL_ZOOM).then(() => {
 | 
				
			||||||
            WZoom.create('#' + this.$imageView.attr("id"), {
 | 
					            WZoom.create('#' + this.$imageView.attr("id"), {
 | 
				
			||||||
                maxScale: 10,
 | 
					                maxScale: 10,
 | 
				
			||||||
 | 
					                speed: 20,
 | 
				
			||||||
                zoomOnClick: false
 | 
					                zoomOnClick: false
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user