ctrl + c to copy

This commit is contained in:
Alex Yatskov 2017-03-31 21:48:10 -07:00
parent 1d9e911648
commit 405e487a73
4 changed files with 36 additions and 1 deletions

View File

@ -51,6 +51,10 @@ window.displayFrame = new class extends Display {
window.parent.postMessage('popupClose', '*');
}
selectionCopy() {
window.parent.postMessage('selectionCopy', '*');
}
showOrphaned() {
$('#content').hide();
$('#orphan').show();
@ -77,4 +81,27 @@ window.displayFrame = new class extends Display {
handler(params);
}
}
onKeyDown(e) {
if (super.onKeyDown(e)) {
return true;
}
const handlers = {
67: /* c */ () => {
if (e.ctrlKey) {
this.selectionCopy();
return true;
}
}
};
const handler = handlers[e.keyCode];
if (handler && handler()) {
e.preventDefault();
return true;
}
return false;
}
};

View File

@ -106,6 +106,10 @@ window.driver = new class {
const handlers = {
popupClose: () => {
this.searchClear();
},
selectionCopy: () => {
document.execCommand('copy');
}
};

View File

@ -29,7 +29,8 @@
},
"permissions": [
"<all_urls>",
"storage"
"storage",
"clipboardWrite"
],
"commands": {
"toggle": {

View File

@ -301,7 +301,10 @@ class Display {
const handler = handlers[e.keyCode];
if (handler && handler()) {
e.preventDefault();
return true;
}
return false;
}
sourceBack() {