mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-27 10:03:13 +00:00
Ignore invalid synctex highlights (#5476)
GitOrigin-RevId: 9123a09502f17c1251995b2e7133b345db885107
This commit is contained in:
parent
01f7f19446
commit
61f466afc0
1 changed files with 11 additions and 4 deletions
|
@ -146,12 +146,19 @@ function PdfJsViewer({ url }) {
|
|||
// when highlights are created, build the highlight elements
|
||||
useEffect(() => {
|
||||
if (pdfJsWrapper && highlights?.length) {
|
||||
const elements = highlights.map(highlight =>
|
||||
buildHighlightElement(highlight, pdfJsWrapper.viewer)
|
||||
)
|
||||
const elements = []
|
||||
|
||||
for (const highlight of highlights) {
|
||||
try {
|
||||
const element = buildHighlightElement(highlight, pdfJsWrapper.viewer)
|
||||
elements.push(element)
|
||||
} catch (error) {
|
||||
// ignore invalid highlights
|
||||
}
|
||||
}
|
||||
|
||||
// scroll to the first highlighted element
|
||||
elements[0].scrollIntoView({
|
||||
elements[0]?.scrollIntoView({
|
||||
block: 'start',
|
||||
inline: 'nearest',
|
||||
behavior: 'smooth',
|
||||
|
|
Loading…
Reference in a new issue