Merge pull request #18244 from Snuffleupagus/CSS-copyAll

Improve how the wait-cursor is toggled when copying all text
This commit is contained in:
Tim van der Meij 2024-06-14 18:23:03 +02:00 committed by GitHub
commit f9693b4d16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 7 deletions

View File

@ -71,6 +71,10 @@
--hcm-highlight-filter: invert(100%); --hcm-highlight-filter: invert(100%);
} }
&.copyAll {
cursor: wait;
}
.canvasWrapper { .canvasWrapper {
overflow: hidden; overflow: hidden;
width: 100%; width: 100%;

View File

@ -740,12 +740,15 @@ class PDFViewer {
// getAllText and we could just get text from the Selection object. // getAllText and we could just get text from the Selection object.
// Select all the document. // Select all the document.
const savedCursor = this.container.style.cursor; const { classList } = this.viewer;
this.container.style.cursor = "wait"; classList.add("copyAll");
const interruptCopy = ev => const ac = new AbortController();
(this.#interruptCopyCondition = ev.key === "Escape"); window.addEventListener(
window.addEventListener("keydown", interruptCopy); "keydown",
ev => (this.#interruptCopyCondition = ev.key === "Escape"),
{ signal: ac.signal }
);
this.getAllText() this.getAllText()
.then(async text => { .then(async text => {
@ -761,8 +764,8 @@ class PDFViewer {
.finally(() => { .finally(() => {
this.#getAllTextInProgress = false; this.#getAllTextInProgress = false;
this.#interruptCopyCondition = false; this.#interruptCopyCondition = false;
window.removeEventListener("keydown", interruptCopy); ac.abort();
this.container.style.cursor = savedCursor; classList.remove("copyAll");
}); });
event.preventDefault(); event.preventDefault();