feat(print): allow custom CSS (closes #7608)

This commit is contained in:
Elian Doran 2025-11-07 17:25:05 +02:00
parent e28da416ba
commit 7a677cff5f
No known key found for this signature in database

View File

@ -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();