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);