Skip to content

Build your personal knowledge base with Trilium Notes

feat(footnotes): clicking a footnote from the bottom list navigates to ref

Elian Doraneee22eaa1fbf
diff --git a/src/public/app/services/link.ts b/src/public/app/services/link.ts
index 534bc8c4d9..2874ffea97 100644
--- a/src/public/app/services/link.ts
+++ b/src/public/app/services/link.ts
@@ -242,6 +242,10 @@ function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent, hrefLink: string | und
evt.preventDefault();
evt.stopPropagation();
+ if (hrefLink?.startsWith("#fnref")) {
+ return handleFootnote(hrefLink, $link);
+ }
+
const {notePath, viewScope} = parseNavigationStateFromUrl(hrefLink);
const ctrlKey = utils.isCtrlKey(evt);
@@ -301,6 +305,15 @@ function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent, hrefLink: string | und
return true;
}
+function handleFootnote(hrefLink: string, $link: JQuery<HTMLElement>) {
+ const el = $link.closest(".ck-content")
+ .find(hrefLink)[0];
+ if (el) {
+ el.scrollIntoView({ behavior: "smooth", block: "center" })
+ }
+ return true;
+}
+
function linkContextMenu(e: PointerEvent) {
const $link = $(e.target as any).closest("a");
const url = $link.attr("href") || $link.attr("data-href");
diff --git a/src/public/app/services/note_tooltip.ts b/src/public/app/services/note_tooltip.ts
index 42661e2ca7..2ae0f47b78 100644
--- a/src/public/app/services/note_tooltip.ts
+++ b/src/public/app/services/note_tooltip.ts
@@ -46,6 +46,11 @@ async function mouseEnterHandler(this: HTMLElement) {
const url = $link.attr("href") || $link.attr("data-href");
const { notePath, noteId, viewScope } = linkService.parseNavigationStateFromUrl(url);
+ if (url?.startsWith("#fnref")) {
+ // The "^" symbol from footnotes within text notes, doesn't require a tooltip.
+ return;
+ }
+
if (!notePath || !noteId || viewScope?.viewMode !== 'default') {
return;
}