diff --git a/apps/client/src/print.tsx b/apps/client/src/print.tsx index 3dbdf1de0..88100c4cb 100644 --- a/apps/client/src/print.tsx +++ b/apps/client/src/print.tsx @@ -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();