Elian Doran ce4f46c226
Some checks failed
Checks / main (push) Has been cancelled
chore(share): fix relative imports
2025-10-29 19:13:11 +02:00

57 lines
1.5 KiB
TypeScript

import setupToC from "./modules/toc.js";
import setupExpanders from "./modules/expanders.js";
import setupMobileMenu from "./modules/mobile.js";
import setupSearch from "./modules/search.js";
import setupThemeSelector from "./modules/theme.js";
import setupMermaid from "./modules/mermaid.js";
import setupMath from "./modules/math.js";
import api from "./modules/api.js";
import "highlight.js/styles/default.css";
import "@triliumnext/ckeditor5/src/theme/ck-content.css";
function $try<T extends (...a: unknown[]) => unknown>(func: T, ...args: Parameters<T>) {
try {
func.apply(func, args);
}
catch (e) {
console.error(e); // eslint-disable-line no-console
}
}
Object.assign(window, api);
$try(setupThemeSelector);
$try(setupToC);
$try(setupExpanders);
$try(setupMobileMenu);
$try(setupSearch);
function setupTextNote() {
$try(setupMermaid);
$try(setupMath);
}
document.addEventListener(
"DOMContentLoaded",
() => {
const noteType = determineNoteType();
if (noteType === "text") {
setupTextNote();
}
const toggleMenuButton = document.getElementById("toggleMenuButton");
const layout = document.getElementById("layout");
if (toggleMenuButton && layout) {
toggleMenuButton.addEventListener("click", () => layout.classList.toggle("showMenu"));
}
},
false
);
function determineNoteType() {
const bodyClass = document.body.className;
const match = bodyClass.match(/type-([^\s]+)/);
return match ? match[1] : null;
}