From ee4d0fa6186b47d7b63e9de57663dd677eddbb6c Mon Sep 17 00:00:00 2001 From: Jaronim Pracht Date: Sun, 15 Jun 2025 18:08:17 +0200 Subject: [PATCH] fix highlighting on elements on page end --- project/frontend/src/components/pdfViewer.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/project/frontend/src/components/pdfViewer.tsx b/project/frontend/src/components/pdfViewer.tsx index 972f5f5..ee68c8d 100644 --- a/project/frontend/src/components/pdfViewer.tsx +++ b/project/frontend/src/components/pdfViewer.tsx @@ -10,8 +10,8 @@ import type { OnGetTextSuccess, } from "node_modules/react-pdf/dist/esm/shared/types"; import { socket } from "../socket"; -import { highlightPattern } from "../util/highlighting"; import { API_HOST } from "../util/api"; +import { highlightPattern } from "../util/highlighting"; interface PDFViewerProps { pitchBookId: string; @@ -111,7 +111,8 @@ export default function PDFViewer({ ) { for ( let k = textItems[i].i; - k < textItems[i + s.split(" ").length].i; + k < textItems[i + s.split(" ").length]?.i || + k < textItems[i + s.split(" ").length - 1]?.i; k++ ) { tmpPos.push(textContent[k].posKey); @@ -129,7 +130,8 @@ export default function PDFViewer({ ) { for ( let k = textItems[i].i; - k < textItems[i + focusHighlight.text.split(" ").length].i; + k < textItems[i + focusHighlight.text.split(" ").length]?.i || + k < textItems[i + focusHighlight.text.split(" ").length - 1]?.i; k++ ) { tmpPosHighlight.push(textContent[k].posKey);