Notes/apps/client/src/share.ts

39 lines
1.1 KiB
TypeScript
Raw Normal View History

2025-05-17 10:03:37 +03:00
import "normalize.css";
2025-05-17 10:13:03 +03:00
import "@triliumnext/ckeditor5/content.css";
2025-06-09 14:13:35 +03:00
import "@triliumnext/share-theme/styles/index.css";
import "@triliumnext/share-theme/scripts/index.js";
/**
* Fetch note with given ID from backend
*
* @param noteId of the given note to be fetched. If false, fetches current note.
*/
2025-01-26 20:54:30 +01:00
async function fetchNote(noteId: string | null = null) {
if (!noteId) {
2022-01-01 22:32:38 +01:00
noteId = document.body.getAttribute("data-note-id");
}
2022-01-01 22:32:38 +01:00
const resp = await fetch(`api/notes/${noteId}`);
return await resp.json();
}
2025-01-09 18:07:02 +02:00
document.addEventListener(
"DOMContentLoaded",
() => {
const toggleMenuButton = document.getElementById("toggleMenuButton");
const layout = document.getElementById("layout");
2025-01-09 18:07:02 +02:00
if (toggleMenuButton && layout) {
toggleMenuButton.addEventListener("click", () => layout.classList.toggle("showMenu"));
}
},
false
);
// workaround to prevent webpack from removing "fetchNote" as dead code:
// add fetchNote as property to the window object
Object.defineProperty(window, "fetchNote", {
value: fetchNote
2025-03-02 20:47:57 +01:00
});