Prevent mouse interaction with form elements in PresentationMode (issue 12232)

This commit is contained in:
Jonas Jenwald 2022-10-30 16:11:31 +01:00
parent c059c13785
commit f0811a4a3c
3 changed files with 29 additions and 22 deletions

View File

@ -645,6 +645,10 @@ class LinkAnnotationElement extends AnnotationElement {
return this.container; return this.container;
} }
#setInternalLink() {
this.container.setAttribute("data-internal-link", "");
}
/** /**
* Bind internal links to the link element. * Bind internal links to the link element.
* *
@ -662,7 +666,7 @@ class LinkAnnotationElement extends AnnotationElement {
return false; return false;
}; };
if (destination || destination === /* isTooltipOnly = */ "") { if (destination || destination === /* isTooltipOnly = */ "") {
link.className = "internalLink"; this.#setInternalLink();
} }
} }
@ -680,7 +684,7 @@ class LinkAnnotationElement extends AnnotationElement {
this.linkService.executeNamedAction(action); this.linkService.executeNamedAction(action);
return false; return false;
}; };
link.className = "internalLink"; this.#setInternalLink();
} }
/** /**
@ -698,7 +702,7 @@ class LinkAnnotationElement extends AnnotationElement {
); );
return false; return false;
}; };
link.className = "internalLink"; this.#setInternalLink();
} }
/** /**
@ -712,7 +716,7 @@ class LinkAnnotationElement extends AnnotationElement {
this.linkService.executeSetOCGState(action); this.linkService.executeSetOCGState(action);
return false; return false;
}; };
link.className = "internalLink"; this.#setInternalLink();
} }
/** /**
@ -750,7 +754,7 @@ class LinkAnnotationElement extends AnnotationElement {
if (!link.onclick) { if (!link.onclick) {
link.onclick = () => false; link.onclick = () => false;
} }
link.className = "internalLink"; this.#setInternalLink();
} }
_bindResetFormAction(link, resetForm) { _bindResetFormAction(link, resetForm) {
@ -758,7 +762,7 @@ class LinkAnnotationElement extends AnnotationElement {
if (!otherClickAction) { if (!otherClickAction) {
link.href = this.linkService.getAnchorUrl(""); link.href = this.linkService.getAnchorUrl("");
} }
link.className = "internalLink"; this.#setInternalLink();
if (!this._fieldObjects) { if (!this._fieldObjects) {
warn( warn(

View File

@ -224,21 +224,24 @@ class PDFPresentationMode {
evt.preventDefault(); evt.preventDefault();
return; return;
} }
if (evt.button === 0) { if (evt.button !== 0) {
// Enable clicking of links in presentation mode. Note: only links return;
// pointing to destinations in the current PDF document work. }
const isInternalLink = // Enable clicking of links in presentation mode. Note: only links
evt.target.href && evt.target.classList.contains("internalLink"); // pointing to destinations in the current PDF document work.
if (!isInternalLink) { if (
// Unless an internal link was clicked, advance one page. evt.target.href &&
evt.preventDefault(); evt.target.parentNode?.hasAttribute("data-internal-link")
) {
return;
}
// Unless an internal link was clicked, advance one page.
evt.preventDefault();
if (evt.shiftKey) { if (evt.shiftKey) {
this.pdfViewer.previousPage(); this.pdfViewer.previousPage();
} else { } else {
this.pdfViewer.nextPage(); this.pdfViewer.nextPage();
}
}
} }
} }

View File

@ -222,8 +222,8 @@ body {
user-select: none; user-select: none;
} }
.pdfPresentationMode:fullscreen a:not(.internalLink) { .pdfPresentationMode:fullscreen section:not([data-internal-link]) {
display: none; pointer-events: none;
} }
.pdfPresentationMode:fullscreen .textLayer span { .pdfPresentationMode:fullscreen .textLayer span {