mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-30 03:32:26 +08:00
feat(footnotes): clicking a footnote from the bottom list navigates to ref
This commit is contained in:
parent
3f65fb83cb
commit
eee22eaa1f
@ -242,6 +242,10 @@ function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent, hrefLink: string | und
|
|||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
|
|
||||||
|
if (hrefLink?.startsWith("#fnref")) {
|
||||||
|
return handleFootnote(hrefLink, $link);
|
||||||
|
}
|
||||||
|
|
||||||
const {notePath, viewScope} = parseNavigationStateFromUrl(hrefLink);
|
const {notePath, viewScope} = parseNavigationStateFromUrl(hrefLink);
|
||||||
|
|
||||||
const ctrlKey = utils.isCtrlKey(evt);
|
const ctrlKey = utils.isCtrlKey(evt);
|
||||||
@ -301,6 +305,15 @@ function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent, hrefLink: string | und
|
|||||||
return true;
|
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) {
|
function linkContextMenu(e: PointerEvent) {
|
||||||
const $link = $(e.target as any).closest("a");
|
const $link = $(e.target as any).closest("a");
|
||||||
const url = $link.attr("href") || $link.attr("data-href");
|
const url = $link.attr("href") || $link.attr("data-href");
|
||||||
|
@ -46,6 +46,11 @@ async function mouseEnterHandler(this: HTMLElement) {
|
|||||||
const url = $link.attr("href") || $link.attr("data-href");
|
const url = $link.attr("href") || $link.attr("data-href");
|
||||||
const { notePath, noteId, viewScope } = linkService.parseNavigationStateFromUrl(url);
|
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') {
|
if (!notePath || !noteId || viewScope?.viewMode !== 'default') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user