From 24db3f4d86f9ac6ade398794a9b8cdba4ce84cf0 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Fri, 18 Aug 2023 12:45:34 -0400 Subject: [PATCH] Allow clicking annotated links in EPUB/snapshot https://forums.zotero.org/discussion/106960/zotero-7-highlighting-breaks-links-in-epub --- src/dom/common/components/overlay/annotation-overlay.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dom/common/components/overlay/annotation-overlay.tsx b/src/dom/common/components/overlay/annotation-overlay.tsx index a1623a88..93dba266 100644 --- a/src/dom/common/components/overlay/annotation-overlay.tsx +++ b/src/dom/common/components/overlay/annotation-overlay.tsx @@ -215,7 +215,9 @@ const HighlightOrUnderline: React.FC = (props) => { }; let rects = new Map(); + let interactiveElementRects = new Set(); for (let range of ranges) { + let closestInteractiveElement = range.startContainer.parentElement?.closest('a, area'); for (let rect of range.getClientRects()) { if (rect.width == 0 || rect.height == 0) { continue; @@ -225,6 +227,9 @@ const HighlightOrUnderline: React.FC = (props) => { let key = JSON.stringify(rect); if (!rects.has(key)) { rects.set(key, rect); + if (closestInteractiveElement) { + interactiveElementRects.add(rect); + } } } } @@ -275,7 +280,7 @@ const HighlightOrUnderline: React.FC = (props) => { // @ts-ignore xmlns="http://www.w3.org/1999/xhtml" style={{ - pointerEvents: 'auto', + pointerEvents: interactiveElementRects.has(rect) ? 'none' : 'auto', cursor: 'default', width: '100%', height: '100%',