Uh oh!
There was an error while loading. Please reload this page.
forked from andreivmaksimov/python_data_science
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel.js
More file actions
Latest commit
33 lines (29 loc) · 1.2 KB
/
Copy pathkernel.js
File metadata and controls
33 lines (29 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
constextra_map=(notebook,cell)=>({
['Alt--'](cm){
cm.replaceSelection(' <- ')
},
['Shift-Ctrl-M'](cm){
cm.replaceSelection(' %>% ')
},
F1(cm){
const{anchor, head}=cm.findWordAt(cm.getCursor())
constword=cm.getRange(anchor,head)
constcallbacks=cell.get_callbacks()
constoptions={silent: false,store_history: false,stop_on_error: true}
cell.last_msg_id=notebook.kernel.execute(`help(${word})`,callbacks,options)
},
})
functionenable_extra_keys(notebook,cell){
if(!cell.code_mirror)return
constold_keymap=cell.code_mirror.getOption('extraKeys')
constnew_keymap=Object.assign({},old_keymap,extra_map(notebook,cell))
cell.code_mirror.setOption('extraKeys',new_keymap)
}
define(['base/js/namespace'],({notebook})=>({
onload(){
for(letcellofnotebook.get_cells())
enable_extra_keys(notebook,cell)
notebook.events.on('edit_mode.Cell',(event,{cell})=>
enable_extra_keys(notebook,cell))
},
}))