mirror of
https://github.com/zadam/trilium.git
synced 2025-11-10 16:39:02 +01:00
feat(print): allow custom CSS (closes #7608)
This commit is contained in:
parent
e28da416ba
commit
7a677cff5f
@ -70,6 +70,9 @@ function SingleNoteRenderer({ note, onReady }: RendererProps) {
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
// Check custom CSS.
|
||||
await loadCustomCss(note);
|
||||
}
|
||||
|
||||
load().then(() => requestAnimationFrame(onReady))
|
||||
@ -102,4 +105,17 @@ function Error404({ noteId }: { noteId: string }) {
|
||||
)
|
||||
}
|
||||
|
||||
async function loadCustomCss(note: FNote) {
|
||||
const printCssNotes = await note.getRelationTargets("printCss");
|
||||
|
||||
for (const printCssNote of printCssNotes) {
|
||||
if (!printCssNote || (printCssNote.type !== "code" && printCssNote.mime !== "text/css")) continue;
|
||||
|
||||
const linkEl = document.createElement("link");
|
||||
linkEl.href = `/api/notes/${printCssNote.noteId}/download`;
|
||||
linkEl.rel = "stylesheet";
|
||||
document.head.appendChild(linkEl);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user