Add "Paste and Search" option to lookup context menu (#4636)
Some checks are pending
CI / Build, Upload, Test (push) Waiting to run
Some checks are pending
CI / Build, Upload, Test (push) Waiting to run
This commit is contained in:
parent
8d7e9cc0e3
commit
aed604ddc0
3 changed files with 28 additions and 4 deletions
|
@ -209,9 +209,7 @@ var Zotero_Lookup = new function () {
|
||||||
|
|
||||||
|
|
||||||
this.getActivePanel = function() {
|
this.getActivePanel = function() {
|
||||||
var mlPanel = document.getElementById("zotero-lookup-multiline");
|
return document.getElementById("zotero-lookup-multiline");
|
||||||
if (mlPanel.hidden) return document.getElementById("zotero-lookup-singleLine");
|
|
||||||
return mlPanel;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -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) {
|
this.setMultiline = function (on) {
|
||||||
var mlTxtBox = document.getElementById("zotero-lookup-textbox");
|
var mlTxtBox = document.getElementById("zotero-lookup-textbox");
|
||||||
|
|
|
@ -1223,7 +1223,7 @@
|
||||||
class="zotero-tb-button"
|
class="zotero-tb-button"
|
||||||
tooltiptext="&zotero.toolbar.lookup.label;"
|
tooltiptext="&zotero.toolbar.lookup.label;"
|
||||||
type="panel"
|
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"
|
<panel id="zotero-lookup-panel" type="arrow"
|
||||||
|
@ -1238,6 +1238,7 @@
|
||||||
id="zotero-lookup-textbox"
|
id="zotero-lookup-textbox"
|
||||||
onkeypress="Zotero_Lookup.onKeyPress(event, this)"
|
onkeypress="Zotero_Lookup.onKeyPress(event, this)"
|
||||||
oninput="Zotero_Lookup.onInput(event, this)"
|
oninput="Zotero_Lookup.onInput(event, this)"
|
||||||
|
oncontextmenu="Zotero_Lookup.onContextMenu(event, this)"
|
||||||
rows="1"
|
rows="1"
|
||||||
wrap="off"/>
|
wrap="off"/>
|
||||||
<hbox id="zotero-lookup-buttons" align="start" hidden="true">
|
<hbox id="zotero-lookup-buttons" align="start" hidden="true">
|
||||||
|
|
|
@ -671,3 +671,6 @@ post-upgrade-remind-me-later =
|
||||||
.label = { general-remind-me-later }
|
.label = { general-remind-me-later }
|
||||||
post-upgrade-done =
|
post-upgrade-done =
|
||||||
.label = { general-done }
|
.label = { general-done }
|
||||||
|
|
||||||
|
text-action-paste-and-search =
|
||||||
|
.label = Paste and Search
|
||||||
|
|
Loading…
Reference in a new issue