Skip to content

Commit

Permalink
Merge pull request #107 from brandfolder/master
Browse files Browse the repository at this point in the history
Allow pasting in all browsers
  • Loading branch information
gsamokovarov committed Feb 12, 2015
2 parents c4c5d71 + b3199a0 commit b0fe646
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
31 changes: 15 additions & 16 deletions lib/web_console/templates/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,26 +311,25 @@ REPLConsole.prototype.onKeyDown = function(ev) {
this.deleteAtCurrent();
ev.preventDefault();
break;
case 86:
// ctrl/command-v
if (ev.ctrlKey || ev.metaKey) {
// Let the pasted text go to our clipboard.
this.clipboard.focus();

// Pasting to clipboard doesn't happen immediately,
// so we have to wait for a while to get the pasted text.
var _this = this;
setTimeout(function() {
_this.addToInput(_this.clipboard.value);
_this.clipboard.value = "";
_this.clipboard.blur();
}, 10);
}
break;
default:
break;
}

if (ev.ctrlKey || ev.metaKey) {
// Set focus to our clipboard in case they hit the "v" key
this.clipboard.focus();
if (ev.keyCode == 86) {
// Pasting to clipboard doesn't happen immediately,
// so we have to wait for a while to get the pasted text.
var _this = this;
setTimeout(function() {
_this.addToInput(_this.clipboard.value);
_this.clipboard.value = "";
_this.clipboard.blur();
}, 10);
}
}

ev.stopPropagation();
};

Expand Down
2 changes: 1 addition & 1 deletion lib/web_console/templates/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#console pre.console-message { color: #1AD027; margin: 0; border: 0; white-space: pre-wrap; background-color: #333; padding: 0; }
#console div.console-focus span.console-cursor { background: #FEFEFE; color: #333; font-weight: bold; }
#console div#resizer { width: 100%; height: 4px; cursor: ns-resize; }
#console input#clipboard { visibility: hidden; }
#console input#clipboard { height: 0px; padding: 0px; margin: 0px; width: 0px; margin-left: -1000px; }
#console span.console-prompt-label { display: inline; color: #FFF; background: none repeat scroll 0% 0% #333; border: 0; padding: 0; }
#console pre.console-prompt-display { display: inline; color: #FFF; background: none repeat scroll 0% 0% #333; border: 0; padding: 0; }

0 comments on commit b0fe646

Please sign in to comment.