Add "Paste and Search" option to lookup context menu (#4636)
Some checks are pending
CI / Build, Upload, Test (push) Waiting to run

This commit is contained in:
Abe Jellinek 2024-08-28 23:36:15 -04:00 committed by GitHub
parent 8d7e9cc0e3
commit aed604ddc0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 4 deletions

View file

@ -209,9 +209,7 @@ var Zotero_Lookup = new function () {
this.getActivePanel = function() {
var mlPanel = document.getElementById("zotero-lookup-multiline");
if (mlPanel.hidden) return document.getElementById("zotero-lookup-singleLine");
return mlPanel;
return document.getElementById("zotero-lookup-multiline");
};
@ -254,6 +252,28 @@ var Zotero_Lookup = new function () {
}
};
this.onContextMenu = function (event, textBox) {
event.preventDefault();
let menu = goBuildEditContextMenu().cloneNode(true);
goUpdateGlobalEditMenuItems(true);
let pasteMenuitem = menu.querySelector("menuitem[data-action='paste']");
let pasteCommand = document.getElementById("cmd_paste");
let pasteAndSearchMenuitem = document.createXULElement("menuitem");
document.l10n.setAttributes(pasteAndSearchMenuitem, "text-action-paste-and-search");
pasteAndSearchMenuitem.disabled = pasteCommand.hasAttribute("disabled"); // no 'disabled' property
pasteAndSearchMenuitem.addEventListener("command", () => {
pasteCommand.doCommand();
this.accept(textBox);
});
pasteMenuitem.after(pasteAndSearchMenuitem);
document.querySelector("popupset").append(menu);
menu.addEventListener("popuphiding", () => menu.remove(),
{ once: true });
menu.openPopupAtScreen(event.screenX, event.screenY, true);
};
this.setMultiline = function (on) {
var mlTxtBox = document.getElementById("zotero-lookup-textbox");

View file

@ -1223,7 +1223,7 @@
class="zotero-tb-button"
tooltiptext="&zotero.toolbar.lookup.label;"
type="panel"
onmousedown="if (this.disabled) { event.preventDefault(); return; } Zotero_Lookup.showPanel(this)"
onmousedown="Zotero_Lookup.handleToolbarButtonMouseDown(event)"
/>
<panel id="zotero-lookup-panel" type="arrow"
@ -1238,6 +1238,7 @@
id="zotero-lookup-textbox"
onkeypress="Zotero_Lookup.onKeyPress(event, this)"
oninput="Zotero_Lookup.onInput(event, this)"
oncontextmenu="Zotero_Lookup.onContextMenu(event, this)"
rows="1"
wrap="off"/>
<hbox id="zotero-lookup-buttons" align="start" hidden="true">

View file

@ -671,3 +671,6 @@ post-upgrade-remind-me-later =
.label = { general-remind-me-later }
post-upgrade-done =
.label = { general-done }
text-action-paste-and-search =
.label = Paste and Search