Skip to content

Build your personal knowledge base with Trilium Notes

refactor(share): check note type

Elian Doran7fdef3418a30
diff --git a/apps/client/src/share.ts b/apps/client/src/share.ts
index a1e348336f..692f9f5ddb 100644
--- a/apps/client/src/share.ts
+++ b/apps/client/src/share.ts
@@ -47,8 +47,12 @@ async function fetchNote(noteId: string | null = null) {
document.addEventListener(
"DOMContentLoaded",
() => {
- formatCodeBlocks();
- applyMath();
+ const noteType = determineNoteType();
+
+ if (noteType === "text") {
+ formatCodeBlocks();
+ applyMath();
+ }
const toggleMenuButton = document.getElementById("toggleMenuButton");
const layout = document.getElementById("layout");
@@ -60,6 +64,12 @@ document.addEventListener(
false
);
+function determineNoteType() {
+ const bodyClass = document.body.className;
+ const match = bodyClass.match(/type-([^\s]+)/);
+ return match ? match[1] : null;
+}
+
// workaround to prevent webpack from removing "fetchNote" as dead code:
// add fetchNote as property to the window object
Object.defineProperty(window, "fetchNote", {