mirror of
https://github.com/zadam/trilium.git
synced 2025-11-09 16:08:58 +01:00
feat(print): support CSS for collections too
Some checks are pending
Checks / main (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Deploy Documentation / Build and Deploy Documentation (push) Waiting to run
Dev / Test development (push) Waiting to run
Dev / Build Docker image (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile) (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile.alpine) (push) Blocked by required conditions
/ Check Docker build (Dockerfile) (push) Waiting to run
/ Check Docker build (Dockerfile.alpine) (push) Waiting to run
/ Build Docker images (Dockerfile, ubuntu-24.04-arm, linux/arm64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.alpine, ubuntu-latest, linux/amd64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v7) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v8) (push) Blocked by required conditions
/ Merge manifest lists (push) Blocked by required conditions
playwright / main (push) Waiting to run
Some checks are pending
Checks / main (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Deploy Documentation / Build and Deploy Documentation (push) Waiting to run
Dev / Test development (push) Waiting to run
Dev / Build Docker image (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile) (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile.alpine) (push) Blocked by required conditions
/ Check Docker build (Dockerfile) (push) Waiting to run
/ Check Docker build (Dockerfile.alpine) (push) Waiting to run
/ Build Docker images (Dockerfile, ubuntu-24.04-arm, linux/arm64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.alpine, ubuntu-latest, linux/amd64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v7) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v8) (push) Blocked by required conditions
/ Merge manifest lists (push) Blocked by required conditions
playwright / main (push) Waiting to run
This commit is contained in:
parent
e4cd946ea8
commit
71d7403690
@ -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();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user