Skip to content

Commit

Permalink
Allow clicking annotated links in EPUB/snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
AbeJellinek committed Aug 18, 2023
1 parent b341bea commit 24db3f4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/dom/common/components/overlay/annotation-overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ const HighlightOrUnderline: React.FC<HighlightOrUnderlineProps> = (props) => {
};

let rects = new Map<string, DOMRect>();
let interactiveElementRects = new Set<DOMRect>();
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;
Expand All @@ -225,6 +227,9 @@ const HighlightOrUnderline: React.FC<HighlightOrUnderlineProps> = (props) => {
let key = JSON.stringify(rect);
if (!rects.has(key)) {
rects.set(key, rect);
if (closestInteractiveElement) {
interactiveElementRects.add(rect);
}
}
}
}
Expand Down Expand Up @@ -275,7 +280,7 @@ const HighlightOrUnderline: React.FC<HighlightOrUnderlineProps> = (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%',
Expand Down

0 comments on commit 24db3f4

Please sign in to comment.