mirror of
https://github.com/zadam/trilium.git
synced 2025-11-16 10:15:52 +01:00
feat(print): support CSS for collections too
This commit is contained in:
@@ -92,7 +92,10 @@ function CollectionRenderer({ note, onReady }: RendererProps) {
|
|||||||
ntxId="print"
|
ntxId="print"
|
||||||
highlightedTokens={null}
|
highlightedTokens={null}
|
||||||
media="print"
|
media="print"
|
||||||
onReady={onReady}
|
onReady={async () => {
|
||||||
|
await loadCustomCss(note);
|
||||||
|
onReady();
|
||||||
|
}}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +110,7 @@ function Error404({ noteId }: { noteId: string }) {
|
|||||||
|
|
||||||
async function loadCustomCss(note: FNote) {
|
async function loadCustomCss(note: FNote) {
|
||||||
const printCssNotes = await note.getRelationTargets("printCss");
|
const printCssNotes = await note.getRelationTargets("printCss");
|
||||||
|
let loadPromises: JQueryPromise<void>[] = [];
|
||||||
|
|
||||||
for (const printCssNote of printCssNotes) {
|
for (const printCssNote of printCssNotes) {
|
||||||
if (!printCssNote || (printCssNote.type !== "code" && printCssNote.mime !== "text/css")) continue;
|
if (!printCssNote || (printCssNote.type !== "code" && printCssNote.mime !== "text/css")) continue;
|
||||||
@@ -114,8 +118,15 @@ async function loadCustomCss(note: FNote) {
|
|||||||
const linkEl = document.createElement("link");
|
const linkEl = document.createElement("link");
|
||||||
linkEl.href = `/api/notes/${printCssNote.noteId}/download`;
|
linkEl.href = `/api/notes/${printCssNote.noteId}/download`;
|
||||||
linkEl.rel = "stylesheet";
|
linkEl.rel = "stylesheet";
|
||||||
|
|
||||||
|
const promise = $.Deferred();
|
||||||
|
loadPromises.push(promise.promise());
|
||||||
|
linkEl.onload = () => promise.resolve();
|
||||||
|
|
||||||
document.head.appendChild(linkEl);
|
document.head.appendChild(linkEl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await Promise.allSettled(loadPromises);
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|||||||
Reference in New Issue
Block a user