Skip to content

Commit

Permalink
Merge pull request #74 from dansseg/master
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 committed Feb 17, 2023
2 parents 925038c + 13f060a commit ca472d8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/PageTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ function getPageRef(element: HTMLElement) {
getBlockContentPageRef(el) ??
getSidebarPageRef(el) ??
getReferencesPageRef(el) ??
getSearchMenuPageRef(el)
getSearchMenuPageRef(el) ??
getFavoritesOrRecentPageRef(el)
);
}

Expand Down Expand Up @@ -250,6 +251,17 @@ function getReferencesPageRef(element: HTMLElement) {
}
}

function getFavoritesOrRecentPageRef(element: HTMLElement) {
const el = element as HTMLAnchorElement;
if (el.tagName === "SPAN" && el.classList.contains("page-title")) {
const parentListItem = el.closest("li");

if (parentListItem?.classList.contains("favorite-item") || parentListItem?.classList.contains("recent-item")) {
return parentListItem.getAttribute("data-ref");
}
}
}

function getClosestSearchMenuLink(element: HTMLElement): HTMLElement | null {
return element.closest(".search-results-wrap .menu-link");
}
Expand All @@ -276,6 +288,7 @@ function getBlockUUID(element: HTMLElement) {
function stop(e: Event) {
e.stopPropagation();
e.stopImmediatePropagation();
e.preventDefault(); // prevent scrolling from middle mouse button click
}

/**
Expand Down

0 comments on commit ca472d8

Please sign in to comment.