Commit 33ca18cb authored by Robert Knight's avatar Robert Knight

Support versions of PDF.js >= v3.2.146

This release includes https://github.com/mozilla/pdf.js/pull/15722 which
changed the property that stores the root of the text layer.

The tests mocks still use the old `textLayerDiv` name because that is
what is used in the PDF.js release that we currently ship.
parent 54ecf795
......@@ -314,7 +314,12 @@ async function anchorByPosition(pageIndex, start, end) {
// `getPageTextContent` and the text layer content. Any other differences
// will cause mis-anchoring.
const root = page.textLayer.textLayerDiv;
const root = page.textLayer.textLayerDiv ?? page.textLayer.div;
if (!root) {
/* istanbul ignore next */
throw new Error('Unable to find PDF.js text layer root');
}
const textLayerStr = /** @type {string} */ (root.textContent);
const [textLayerStart, textLayerEnd] = translateOffsets(
......
......@@ -146,7 +146,8 @@
/**
* @typedef TextLayer
* @prop {boolean} renderingDone
* @prop {HTMLElement} textLayerDiv
* @prop {HTMLElement} [div] - New name for root element of text layer in PDF.js >= v3.2.146
* @prop {HTMLElement} [textLayerDiv] - Old name for root element of text layer
*/
export {};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment