Merge pull request #16902 from Snuffleupagus/FileAttachment-keyboard-download
Support downloading FileAttachment annotations with the keyboard
This commit is contained in:
commit
92792a8215
@ -2745,7 +2745,7 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
|
|||||||
render() {
|
render() {
|
||||||
this.container.classList.add("fileAttachmentAnnotation");
|
this.container.classList.add("fileAttachmentAnnotation");
|
||||||
|
|
||||||
const { data } = this;
|
const { container, data } = this;
|
||||||
let trigger;
|
let trigger;
|
||||||
if (data.hasAppearance || data.fillAlpha === 0) {
|
if (data.hasAppearance || data.fillAlpha === 0) {
|
||||||
trigger = document.createElement("div");
|
trigger = document.createElement("div");
|
||||||
@ -2770,17 +2770,24 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trigger.addEventListener("dblclick", this._download.bind(this));
|
trigger.addEventListener("dblclick", this.#download.bind(this));
|
||||||
this.#trigger = trigger;
|
this.#trigger = trigger;
|
||||||
|
|
||||||
|
const { isMac } = FeatureTest.platform;
|
||||||
|
container.addEventListener("keydown", evt => {
|
||||||
|
if (evt.key === "Enter" && (isMac ? evt.metaKey : evt.ctrlKey)) {
|
||||||
|
this.#download();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (!data.popupRef && this.hasPopupData) {
|
if (!data.popupRef && this.hasPopupData) {
|
||||||
this._createPopup();
|
this._createPopup();
|
||||||
} else {
|
} else {
|
||||||
trigger.classList.add("popupTriggerArea");
|
trigger.classList.add("popupTriggerArea");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.container.append(trigger);
|
container.append(trigger);
|
||||||
return this.container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
getElementsToTriggerPopup() {
|
getElementsToTriggerPopup() {
|
||||||
@ -2793,11 +2800,8 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Download the file attachment associated with this annotation.
|
* Download the file attachment associated with this annotation.
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @memberof FileAttachmentAnnotationElement
|
|
||||||
*/
|
*/
|
||||||
_download() {
|
#download() {
|
||||||
this.downloadManager?.openOrDownloadData(
|
this.downloadManager?.openOrDownloadData(
|
||||||
this.container,
|
this.container,
|
||||||
this.content,
|
this.content,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user