mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-19 13:20:36 +08:00
Allow programmatic copy to clipboard
This commit is contained in:
parent
ee419c0a17
commit
4455bcfc8f
@ -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…
x
Reference in New Issue
Block a user