2025-10-18 21:01:31 +03:00
|
|
|
import FNote from "./entities/fnote";
|
2025-10-18 21:09:39 +03:00
|
|
|
import { render } from "preact";
|
2025-10-18 21:35:19 +03:00
|
|
|
import { CustomNoteList } from "./widgets/collections/NoteList";
|
|
|
|
|
import "./print.css";
|
2025-10-18 21:01:31 +03:00
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
|
const noteId = window.location.pathname.split("/")[2];
|
|
|
|
|
const froca = (await import("./services/froca")).default;
|
|
|
|
|
const note = await froca.getNote(noteId);
|
|
|
|
|
|
|
|
|
|
if (!note) return;
|
2025-10-18 22:11:33 +03:00
|
|
|
render(getElementForNote(note), document.body);
|
2025-10-18 21:35:19 +03:00
|
|
|
}
|
|
|
|
|
|
2025-10-18 22:11:33 +03:00
|
|
|
function getElementForNote(note: FNote) {
|
|
|
|
|
// Collections.
|
|
|
|
|
if (note.type === "book") {
|
|
|
|
|
return <CustomNoteList
|
2025-10-18 21:35:19 +03:00
|
|
|
isEnabled
|
|
|
|
|
note={note}
|
|
|
|
|
notePath={note.getBestNotePath().join("/")}
|
|
|
|
|
ntxId="print"
|
|
|
|
|
highlightedTokens={null}
|
2025-10-18 21:56:10 +03:00
|
|
|
media="print"
|
2025-10-18 22:11:33 +03:00
|
|
|
/>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Other note types.
|
|
|
|
|
return <>
|
|
|
|
|
<h1>{note.title}</h1>
|
|
|
|
|
</>;
|
2025-10-18 21:01:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main();
|