mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 11:56:01 +01:00 
			
		
		
		
	refactor(share): don't load highlighting if not needed
This commit is contained in:
		@@ -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");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user