Skip to content

Print collection - add missing link/titles for reference-link links - #9489

Merged
eliandoran merged 4 commits into
TriliumNext:mainfrom
contributor:print-add-missing-links-alternative
Apr 19, 2026
Merged

Print collection - add missing link/titles for reference-link links#9489
eliandoran merged 4 commits into
TriliumNext:mainfrom
contributor:print-add-missing-links-alternative

Conversation

@contributor

@contributor contributor commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

Reference links were not displayed in printed version. Neither links for collection notes, nor note titles for notes outside of the collection.

Note:
image

Printed version:
image

This PR fixes that

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 18, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an isPrinting flag to the content rendering options to adjust how reference links are processed during printing. While this allows for specialized link handling in print views, the feedback highlights that the flag is not currently propagated to recursive rendering calls, which will lead to inconsistent behavior in nested content. Additionally, the reviewer noted that modifying the anchor tag directly instead of using an inner span may result in style loss when the print view processes the links.

Comment thread apps/client/src/services/content_renderer_text.ts Outdated
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Apr 18, 2026
@contributor

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the postProcessRichContent function to use getAttribute("href") instead of the href property when processing reference links. A review comment suggests optimizing performance by parallelizing the link title loading with Promise.all instead of processing them sequentially in a loop.

Comment on lines 49 to 53
for (const el of referenceLinks) {
const innerSpan = document.createElement("span");
await link.loadReferenceLinkTitle($(innerSpan), el.href);
await link.loadReferenceLinkTitle($(innerSpan), el.getAttribute("href"));
el.replaceChildren(innerSpan);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Processing reference links sequentially with await inside a loop can be inefficient, especially in large documents or print collections where many links might be present. Since the notes are already prefetched at line 47, these calls will likely be fast, but parallelizing them with Promise.all is a better practice to avoid unnecessary sequential blocking and improve rendering performance.

Suggested change
for (const el of referenceLinks) {
const innerSpan = document.createElement("span");
await link.loadReferenceLinkTitle($(innerSpan), el.href);
await link.loadReferenceLinkTitle($(innerSpan), el.getAttribute("href"));
el.replaceChildren(innerSpan);
}
await Promise.all(referenceLinks.toArray().map(async (el) => {
const innerSpan = document.createElement("span");
await link.loadReferenceLinkTitle($(innerSpan), el.getAttribute("href"));
el.replaceChildren(innerSpan);
}));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@contributor contributor changed the title Print collection - add missing links (alternative) Print collection - add missing link/titles for reference-link links Apr 18, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 19, 2026
@eliandoran eliandoran added this to the v0.103.0 milestone Apr 19, 2026
@eliandoran
eliandoran merged commit 8a2b649 into TriliumNext:main Apr 19, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants