fix: following ordinary link in footnotes, closes #559 (#560)

This commit is contained in:
Huang Xin
2025-03-11 01:09:47 +08:00
committed by GitHub
parent dfa0468d24
commit 6a74a0c5b8
2 changed files with 10 additions and 1 deletions
@@ -36,6 +36,15 @@ const FootnotePopup: React.FC<FootnotePopupProps> = ({ bookKey, bookDoc }) => {
const handleBeforeRender = (e: Event) => {
const detail = (e as CustomEvent).detail;
const { view } = detail;
view.addEventListener('link', (e: Event) => {
e.preventDefault();
const { detail: popupLinkDetail } = e as CustomEvent;
popupLinkDetail['follow'] = true;
footnoteHandler.handle(bookDoc, e)?.catch((err) => {
console.warn(err);
getView(bookKey)?.goTo(popupLinkDetail.href);
});
});
footnoteViewRef.current = view;
footnoteRef.current?.replaceChildren(view);
const { renderer } = view;