Merge pull request #3088 from Madhu94/detect-programmatic-copy

Allow programmatic copy to clipboard
pull/3100/merge
Thomas Kluyver 9 years ago committed by GitHub
commit b1e5f729fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -34,10 +34,18 @@ function load_json(clipboard) {
return JSON.parse(s.slice(pix + jcbprefix.length, six));
}
function isProgrammaticCopy(event) {
return (typeof(event.target.selectionStart) !== 'undefined'
&& typeof(event.target.selectionEnd) !== 'undefined'
&& ((event.target.selectionEnd - event.target.selectionStart) > 0));
}
function copy(event) {
if ((Jupyter.notebook.mode !== 'command') ||
// window.getSelection checks if text is selected, e.g. in output
!window.getSelection().isCollapsed) {
!window.getSelection().isCollapsed ||
// Allow programmatic copy
isProgrammaticCopy(event)) {
return;
}
var selecn = Jupyter.notebook.get_selected_cells().map(

Loading…
Cancel
Save