mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Implement scroll to highlight in PDF
This commit is contained in:
parent
4468b038a8
commit
6226131c16
1 changed files with 21 additions and 1 deletions
|
|
@ -447,6 +447,23 @@ export default function PdfArticleContainer(
|
|||
}
|
||||
})
|
||||
|
||||
document.addEventListener('scrollToHighlightId', async (event) => {
|
||||
const annotationId = (event as CustomEvent).detail as string
|
||||
for (let pageIdx = 0; pageIdx < instance.totalPageCount; pageIdx++) {
|
||||
const annotations = await instance.getAnnotations(pageIdx)
|
||||
for (let annIdx = 0; annIdx < annotations.size; annIdx++) {
|
||||
const annotation = annotations.get(annIdx)
|
||||
if (!annotation) {
|
||||
continue
|
||||
}
|
||||
const storedId = annotationOmnivoreId(annotation)
|
||||
if (storedId == annotationId) {
|
||||
instance.jumpToRect(pageIdx, annotation.boundingBox)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return () => {
|
||||
PSPDFKit && container && PSPDFKit.unload(container)
|
||||
}
|
||||
|
|
@ -509,7 +526,10 @@ export default function PdfArticleContainer(
|
|||
props.setShowHighlightsModal(false)
|
||||
}}
|
||||
viewHighlightInReader={(highlightId) => {
|
||||
// TODO: scroll to highlight in PDF
|
||||
const event = new CustomEvent('scrollToHighlightId', {
|
||||
detail: highlightId,
|
||||
})
|
||||
document.dispatchEvent(event)
|
||||
props.setShowHighlightsModal(false)
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue