diff --git a/web/pdf_viewer.css b/web/pdf_viewer.css index e6b9cf729361f..d65173b81b7d5 100644 --- a/web/pdf_viewer.css +++ b/web/pdf_viewer.css @@ -71,6 +71,10 @@ --hcm-highlight-filter: invert(100%); } + &.copyAll { + cursor: wait; + } + .canvasWrapper { overflow: hidden; width: 100%; diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index 187835508979c..570fca03fdd56 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -740,12 +740,15 @@ class PDFViewer { // getAllText and we could just get text from the Selection object. // Select all the document. - const savedCursor = this.container.style.cursor; - this.container.style.cursor = "wait"; - - const interruptCopy = ev => - (this.#interruptCopyCondition = ev.key === "Escape"); - window.addEventListener("keydown", interruptCopy); + const { classList } = this.viewer; + classList.add("copyAll"); + + const ac = new AbortController(); + window.addEventListener( + "keydown", + ev => (this.#interruptCopyCondition = ev.key === "Escape"), + { signal: ac.signal } + ); this.getAllText() .then(async text => { @@ -761,8 +764,8 @@ class PDFViewer { .finally(() => { this.#getAllTextInProgress = false; this.#interruptCopyCondition = false; - window.removeEventListener("keydown", interruptCopy); - this.container.style.cursor = savedCursor; + ac.abort(); + classList.remove("copyAll"); }); event.preventDefault();