mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	refactor(client): missing type errors for syntax highlight
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
				
			|||||||
import { ensureMimeTypes, highlight, highlightAuto, loadTheme, Themes } from "@triliumnext/highlightjs";
 | 
					import { ensureMimeTypes, highlight, highlightAuto, loadTheme, Themes, type AutoHighlightResult, type HighlightResult, type Theme } from "@triliumnext/highlightjs";
 | 
				
			||||||
import mime_types from "./mime_types.js";
 | 
					import mime_types from "./mime_types.js";
 | 
				
			||||||
import options from "./options.js";
 | 
					import options from "./options.js";
 | 
				
			||||||
import toast from "./toast.js";
 | 
					import toast from "./toast.js";
 | 
				
			||||||
@@ -57,7 +57,7 @@ export async function applySingleBlockSyntaxHighlight($codeBlock: JQuery<HTMLEle
 | 
				
			|||||||
    $codeBlock.parent().toggleClass("hljs");
 | 
					    $codeBlock.parent().toggleClass("hljs");
 | 
				
			||||||
    const text = $codeBlock.text();
 | 
					    const text = $codeBlock.text();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let highlightedText = null;
 | 
					    let highlightedText: HighlightResult | AutoHighlightResult | null = null;
 | 
				
			||||||
    if (normalizedMimeType === mime_types.MIME_TYPE_AUTO) {
 | 
					    if (normalizedMimeType === mime_types.MIME_TYPE_AUTO) {
 | 
				
			||||||
        await ensureMimeTypesForHighlighting();
 | 
					        await ensureMimeTypesForHighlighting();
 | 
				
			||||||
        highlightedText = highlightAuto(text);
 | 
					        highlightedText = highlightAuto(text);
 | 
				
			||||||
@@ -89,7 +89,7 @@ export async function ensureMimeTypesForHighlighting() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export function loadHighlightingTheme(themeName: string) {
 | 
					export function loadHighlightingTheme(themeName: string) {
 | 
				
			||||||
    const themePrefix = "default:";
 | 
					    const themePrefix = "default:";
 | 
				
			||||||
    let theme = null;
 | 
					    let theme: Theme | null = null;
 | 
				
			||||||
    if (themeName.includes(themePrefix)) {
 | 
					    if (themeName.includes(themePrefix)) {
 | 
				
			||||||
        theme = Themes[themeName.substring(themePrefix.length)];
 | 
					        theme = Themes[themeName.substring(themePrefix.length)];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,7 @@ import { normalizeMimeTypeForCKEditor, type MimeType } from "@triliumnext/common
 | 
				
			|||||||
import syntaxDefinitions from "./syntax_highlighting.js";
 | 
					import syntaxDefinitions from "./syntax_highlighting.js";
 | 
				
			||||||
import { type Theme } from "./themes.js";
 | 
					import { type Theme } from "./themes.js";
 | 
				
			||||||
import { type HighlightOptions } from "highlight.js";
 | 
					import { type HighlightOptions } from "highlight.js";
 | 
				
			||||||
 | 
					export type { HighlightResult, AutoHighlightResult } from "highlight.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export { default as Themes, type Theme } from "./themes.js";
 | 
					export { default as Themes, type Theme } from "./themes.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user