Merge pull request 'fix highlighting on elements on page end' (#74) from bugfix-highlighting into main

Reviewed-on: #74
pull/75/head
Anastasia Hanna Ougolnikova 2025-06-15 18:57:05 +02:00
commit 10e2996039
1 changed files with 5 additions and 3 deletions

View File

@ -10,8 +10,8 @@ import type {
OnGetTextSuccess, OnGetTextSuccess,
} from "node_modules/react-pdf/dist/esm/shared/types"; } from "node_modules/react-pdf/dist/esm/shared/types";
import { socket } from "../socket"; import { socket } from "../socket";
import { highlightPattern } from "../util/highlighting";
import { API_HOST } from "../util/api"; import { API_HOST } from "../util/api";
import { highlightPattern } from "../util/highlighting";
interface PDFViewerProps { interface PDFViewerProps {
pitchBookId: string; pitchBookId: string;
@ -111,7 +111,8 @@ export default function PDFViewer({
) { ) {
for ( for (
let k = textItems[i].i; 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++ k++
) { ) {
tmpPos.push(textContent[k].posKey); tmpPos.push(textContent[k].posKey);
@ -129,7 +130,8 @@ export default function PDFViewer({
) { ) {
for ( for (
let k = textItems[i].i; 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++ k++
) { ) {
tmpPosHighlight.push(textContent[k].posKey); tmpPosHighlight.push(textContent[k].posKey);