File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
notebook/static/notebook/js Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -34,10 +34,18 @@ function load_json(clipboard) {
34
34
return JSON . parse ( s . slice ( pix + jcbprefix . length , six ) ) ;
35
35
}
36
36
37
+ function isProgrammaticCopy ( event ) {
38
+ return ( typeof ( event . target . selectionStart ) !== 'undefined'
39
+ && typeof ( event . target . selectionEnd ) !== 'undefined'
40
+ && ( ( event . target . selectionEnd - event . target . selectionStart ) > 0 ) ) ;
41
+ }
42
+
37
43
function copy ( event ) {
38
44
if ( ( Jupyter . notebook . mode !== 'command' ) ||
39
45
// window.getSelection checks if text is selected, e.g. in output
40
- ! window . getSelection ( ) . isCollapsed ) {
46
+ ! window . getSelection ( ) . isCollapsed ||
47
+ // Allow programmatic copy
48
+ isProgrammaticCopy ( event ) ) {
41
49
return ;
42
50
}
43
51
var selecn = Jupyter . notebook . get_selected_cells ( ) . map (
You can’t perform that action at this time.
0 commit comments