Attachment box: Add ability to copy URL of snapshot/link (#2748)

Fixes #2747
This commit is contained in:
Abe Jellinek 2022-10-27 16:54:50 -04:00 committed by GitHub
parent 9869eb4bc8
commit 57916c032f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -81,6 +81,12 @@
<note-editor id="attachment-note-editor" notitle="1" flex="1"/>
<button id="select-button" hidden="true"/>
<popupset>
<menupopup id="url-menu">
<menuitem id="url-menuitem-copy"/>
</menupopup>
</popupset>
</vbox>
`, ['chrome://zotero/locale/zotero.dtd']);
}
@ -194,6 +200,16 @@
}
});
this._id('url').addEventListener('contextmenu', (event) => {
this._id('url-menu').openPopupAtScreen(event.screenX, event.screenY, true);
});
let copyMenuitem = this._id('url-menuitem-copy');
copyMenuitem.label = Zotero.getString('general.copy');
copyMenuitem.addEventListener('command', () => {
Zotero.Utilities.Internal.copyTextToClipboard(this.item.getField('url'));
});
this._notifierID = Zotero.Notifier.registerObserver(this, ['item'], 'attachmentbox');
}
@ -279,7 +295,9 @@
urlField.setAttribute('hidden', false);
if (this.clickableLink) {
urlField.onclick = function (event) {
ZoteroPane_Local.loadURI(this.value, event);
if (event.button == 0) {
ZoteroPane_Local.loadURI(this.value, event);
}
};
urlField.className = 'zotero-text-link';
}