Skip to content

Commit

Permalink
fix(highlight): Fix text highlighting for PDFjs upgrade (#698)
Browse files Browse the repository at this point in the history
  • Loading branch information
karelee7 authored Sep 23, 2022
1 parent 6cf6e18 commit bd8b1ff
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/document/docUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export function getSelection(): Selection | null {
// We only care about the last range
let range = selection.getRangeAt(selection.rangeCount - 1);

// Changes to the text layer in PDFjs v2.14.305 require the start range to be set manually for correct highlighting behavior
const startRange = selection.getRangeAt(0);
range.setStart(startRange.startContainer, startRange.startOffset);

const containerEl = findClosestElWithClass(range.endContainer as Element, 'textLayer');
const startPage = getPageNumber(range.startContainer as Element);
const endPage = getPageNumber(range.endContainer as Element);
Expand Down

0 comments on commit bd8b1ff

Please sign in to comment.