chore(highlightjs): introduce client-level list of themes

This commit is contained in:
Elian Doran
2025-05-18 17:12:45 +03:00
parent 488761d4b9
commit 8b11f25f0c
9 changed files with 108 additions and 117 deletions

View File

@@ -1,8 +1,11 @@
import hljs from "../node_modules/highlight.js/es/core.js";
import { normalizeMimeTypeForCKEditor, type MimeType } from "@triliumnext/commons";
import definitions from "./syntax_highlighting.js";
import syntaxDefinitions from "./syntax_highlighting.js";
import { type Theme } from "./themes.js";
import { type HighlightOptions } from "highlight.js";
export { default as Themes } from "./themes.js";
const registeredMimeTypes = new Set<string>();
const unsupportedMimeTypes = new Set<string>();
@@ -18,7 +21,7 @@ export async function ensureMimeTypes(mimeTypes: MimeType[]) {
}
registeredMimeTypes.add(mime);
const loader = definitions[mime];
const loader = syntaxDefinitions[mime];
if (!loader) {
unsupportedMimeTypes.add(mime);
continue;
@@ -42,4 +45,8 @@ export function highlight(code: string, options: HighlightOptions) {
return hljs.highlight(code, options);
}
export async function loadTheme(theme: Theme) {
console.log("Got", theme.default);
}
export const { highlightAuto } = hljs;