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

This commit is contained in:
Elian Doran
2025-01-07 13:40:12 +02:00
parent 3f65fb83cb
commit eee22eaa1f
2 changed files with 18 additions and 0 deletions

View File

@@ -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");