Skip to content

Build your personal knowledge base with Trilium Notes

fix(client): give source and attachment link icons the tn-icon class

matt wilkiebdc100cbbe17
diff --git a/apps/client/src/services/link.spec.ts b/apps/client/src/services/link.spec.ts
index 3a0effad99..0735689984 100644
--- a/apps/client/src/services/link.spec.ts
+++ b/apps/client/src/services/link.spec.ts
@@ -505,7 +505,7 @@ describe("createLink", () => {
showNoteIcon: true,
viewScope: { viewMode: "source" }
});
- expect($el.find("span.bx.bx-code-curly").length).toBe(1);
+ expect($el.find("span.tn-icon.bx.bx-code-curly").length).toBe(1);
});
it("uses an attachments-mode icon when showing the icon for an attachments view", async () => {
@@ -515,7 +515,7 @@ describe("createLink", () => {
showNoteIcon: true,
viewScope: { viewMode: "attachments", attachmentId: "att-x" }
});
- expect($el.find("span.bx.bx-file").length).toBe(1);
+ expect($el.find("span.tn-icon.bx.bx-file").length).toBe(1);
});
it("renders no icon for a view mode without a dedicated icon", async () => {
@@ -953,6 +953,14 @@ describe("loadReferenceLinkTitle", () => {
expect($el.text()).toContain("NoIconRef");
expect($el.children("span").length).toBe(0);
});
+
+ it("gives the source view icon the tn-icon class that the link CSS targets", async () => {
+ const note = buildNote({ title: "SourceRef" });
+ const href = `#root/${note.noteId}?viewMode=source`;
+ const $el = $("<span>").append($("<a>").attr("href", href));
+ await linkService.loadReferenceLinkTitle($el, href);
+ expect($el.children("span.tn-icon.bx-code-curly").length).toBe(1);
+ });
});
describe("module-level click handlers", () => {
diff --git a/apps/client/src/services/link.ts b/apps/client/src/services/link.ts
index 57951769ad..b15752d11d 100644
--- a/apps/client/src/services/link.ts
+++ b/apps/client/src/services/link.ts
@@ -27,9 +27,9 @@ async function getLinkIcon(noteId: string, viewMode: ViewMode | undefined) {
icon = note?.getIcon();
} else if (viewMode === "source") {
- icon = "bx bx-code-curly";
+ icon = "tn-icon bx bx-code-curly";
} else if (viewMode === "attachments") {
- icon = "bx bx-file";
+ icon = "tn-icon bx bx-file";
}
return icon;
}
diff --git a/packages/share-theme/src/styles/content.css b/packages/share-theme/src/styles/content.css
index 393a7e2f01..20bbf614d3 100644
--- a/packages/share-theme/src/styles/content.css
+++ b/packages/share-theme/src/styles/content.css
@@ -57,15 +57,14 @@
}
a.reference-link > span > .tn-icon {
- /* A line can wrap after an inline-block. An inline box that does not wrap and ends with a
- word joiner keeps the icon on the line of the first title character. */
+ /* These three rules must match `.reference-link .tn-icon` in
+ apps/client/src/stylesheets/style.css, which explains them. */
display: inline;
margin-inline-end: 3px;
white-space: nowrap;
}
a.reference-link > span > .tn-icon::before {
- /* An inline-block glyph does not take the underline of the link. */
display: inline-block;
}