diff --git a/web/autolinker.js b/web/autolinker.js index fadf8cb152058..a86b4878fdbca 100644 --- a/web/autolinker.js +++ b/web/autolinker.js @@ -68,8 +68,10 @@ class Autolinker { return linkAnnotations; } - static processLinks(pdfPageView, textContent) { - const [text, diffs] = normalize(textContent.join("")); + static processLinks(pdfPageView) { + const [text, diffs] = normalize( + pdfPageView._textHighlighter.textContentItemsStr.join("") + ); const matches = text.matchAll(Autolinker.#urlRegex); const links = []; for (const match of matches) { diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index 8ac0d14aea4c0..790c55b0bf6b8 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -463,16 +463,15 @@ class PDFPageView { async #renderTextLayer() { if (!this.textLayer) { - return []; + return; } let error = null; - let textContent; try { - textContent = await this.textLayer.render(this.viewport); + await this.textLayer.render(this.viewport); } catch (ex) { if (ex instanceof AbortException) { - return []; + return; } console.error("#renderTextLayer:", ex); error = ex; @@ -480,7 +479,6 @@ class PDFPageView { this.#dispatchLayerRendered("textlayerrendered", error); this.#renderStructTreeLayer(); - return textContent; } /** @@ -1098,10 +1096,9 @@ class PDFPageView { const textLayerP = this.#renderTextLayer(); if (this.annotationLayer) { - await textLayerP; if (this.#enableAutolinking) { - const textContent = await textLayerP; - this.#linkAnnotations = Autolinker.processLinks(this, textContent); + await textLayerP; + this.#linkAnnotations = Autolinker.processLinks(this); } await this.#renderAnnotationLayer(); } diff --git a/web/text_layer_builder.js b/web/text_layer_builder.js index 89adcd967c984..f642382b60643 100644 --- a/web/text_layer_builder.js +++ b/web/text_layer_builder.js @@ -72,7 +72,6 @@ class TextLayerBuilder { * Renders the text layer. * @param {PageViewport} viewport * @param {Object} [textContentParams] - * @returns {Array} */ async render(viewport, textContentParams = null) { if (this.#renderingDone && this.#textLayer) { @@ -81,7 +80,7 @@ class TextLayerBuilder { onBefore: this.hide.bind(this), }); this.show(); - return []; + return; } this.cancel(); @@ -113,7 +112,6 @@ class TextLayerBuilder { this.#onAppend?.(this.div); this.highlighter?.enable(); this.accessibilityManager?.enable(); - return textContentItemsStr; } hide() {