mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	refactor(share): don't load highlighting if not needed
This commit is contained in:
		
							parent
							
								
									ea015bc2cf
								
							
						
					
					
						commit
						0e88818220
					
				| @ -4,11 +4,18 @@ import "boxicons/css/boxicons.min.css"; | |||||||
| import "@triliumnext/share-theme/styles/index.css"; | import "@triliumnext/share-theme/styles/index.css"; | ||||||
| import "@triliumnext/share-theme/scripts/index.js"; | import "@triliumnext/share-theme/scripts/index.js"; | ||||||
| 
 | 
 | ||||||
| import { formatCodeBlocks } from "./services/syntax_highlight.js"; |  | ||||||
| import $ from "jquery"; | import $ from "jquery"; | ||||||
| 
 | 
 | ||||||
| window.$ = $; | window.$ = $; | ||||||
| formatCodeBlocks($("#content")); | 
 | ||||||
|  | async function formatCodeBlocks($container: JQuery<HTMLElement>) { | ||||||
|  |     const codeBlocks = $container.find("pre code"); | ||||||
|  |     if (codeBlocks.length === 0) { | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  |     const { formatCodeBlocks } = await import("./services/syntax_highlight.js"); | ||||||
|  |     await formatCodeBlocks($container); | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Fetch note with given ID from backend |  * Fetch note with given ID from backend | ||||||
| @ -28,6 +35,8 @@ async function fetchNote(noteId: string | null = null) { | |||||||
| document.addEventListener( | document.addEventListener( | ||||||
|     "DOMContentLoaded", |     "DOMContentLoaded", | ||||||
|     () => { |     () => { | ||||||
|  |         formatCodeBlocks($("#content")); | ||||||
|  | 
 | ||||||
|         const toggleMenuButton = document.getElementById("toggleMenuButton"); |         const toggleMenuButton = document.getElementById("toggleMenuButton"); | ||||||
|         const layout = document.getElementById("layout"); |         const layout = document.getElementById("layout"); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran