mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 00:17:57 +01:00
Add 'Copy' MOW context menu item for Windows users.
This commit is contained in:
@@ -149,8 +149,10 @@ const CommandWidgets = Class("CommandWidgets", {
|
||||
multilineOutput: Class.memoize(function () {
|
||||
let elem = document.getElementById("dactyl-multiline-output");
|
||||
elem.contentDocument.body.id = "dactyl-multiline-output-content";
|
||||
document.getElementById("dactyl-context-copylink").style.listStyleImage =
|
||||
util.computedStyle(document.getElementById("context-copylink")).listStyleImage;
|
||||
["copy", "copylink", "selectall"].forEach(function (id) {
|
||||
document.getElementById("dactyl-context-" + id).style.listStyleImage =
|
||||
util.computedStyle(document.getElementById("context-" + id)).listStyleImage;
|
||||
});
|
||||
return elem;
|
||||
}),
|
||||
multilineInput: Class.memoize(function () document.getElementById("dactyl-multiline-input")),
|
||||
@@ -748,6 +750,19 @@ const CommandLine = Module("commandline", {
|
||||
this.timeout(function () { this.widgets.multilineInput.focus(); }, 10);
|
||||
},
|
||||
|
||||
onContext: function onContext(event) {
|
||||
let enabled = {
|
||||
link: window.document.popupNode instanceof HTMLAnchorElement,
|
||||
selection: !window.document.commandDispatcher.focusedWindow.getSelection().isCollapsed
|
||||
};
|
||||
|
||||
for (let [, node] in iter(event.target.childNodes)) {
|
||||
let group = node.getAttributeNS(NS, "group");
|
||||
node.hidden = group && !groups.split(/\s+/).some(function (g) enabled[g]);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles all command-line events. All key events are passed here when
|
||||
* COMMAND_LINE mode is active, as well as all input, keyup, focus, and
|
||||
|
||||
@@ -37,10 +37,16 @@
|
||||
noautohide="true" noautofocus="true"/>
|
||||
|
||||
<menupopup id="dactyl-contextmenu"
|
||||
onpopupshowing="return event.target != this || document.popupNode instanceof HTMLAnchorElement;">
|
||||
onpopupshowing="return (event.target != this || dactyl.modules.commandline.onContext(event));">
|
||||
<menuitem id="dactyl-context-copylink"
|
||||
label="Copy Link Location"
|
||||
label="Copy Link Location" dactyl:group="link"
|
||||
oncommand="goDoCommand('cmd_copyLink');"/>
|
||||
<menuitem id="dactyl-context-copy"
|
||||
label="Copy" dactyl:group="selection"
|
||||
command="cmd_copy"/>
|
||||
<menuitem id="dactyl-context-selectall"
|
||||
label="Select All"
|
||||
command="cmd_selectAll"/>
|
||||
</menupopup>
|
||||
</popupset>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user