Skip to content

Commit 1938d6f

Browse files
committed
2 parents 9caa7e0 + ce6ffab commit 1938d6f

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

notebookjs/src/public/javascripts/index.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ function exec_cell(c_id) {
5050
let output = ("global", eval)(vars_in_scope[id].getValue())
5151
if (Array.isArray(output)) {
5252
output = print_val(output)
53-
} else if (typeof output == 'object' && output !== null) {
53+
}
54+
else if (typeof output === 'object' && output !== null) {
5455
output = JSON.stringify(output)
55-
if (output == "{}") {
56-
output = ""
57-
}
58-
} else if (console) {
56+
}
57+
else if (console) {
5958
//retreive value from the console funcction
6059
console.oldLog = console.log;
6160
console.log = function (value) {
@@ -157,16 +156,13 @@ function add_new_code_cell(c_id, where) {
157156

158157
let editor = CodeMirror(document.getElementById(`div-${new_id}`), {
159158
lineNumbers: true,
160-
tabSize: 4,
159+
tabSize: 2,
161160
mode: 'javascript',
162161
theme: 'monokai',
163-
value: '',
164-
extraKeys: { "Ctrl-Space": "autocomplete" },
165-
autoCloseBrackets: true
162+
value: ''
166163
});
167164
vars_in_scope[`div-${new_id}`] = editor
168165

169-
//show action buttons on hover
170166
$(`#div-${new_id}`)
171167
.mouseover(function () {
172168
$(`#btn-actions-${new_id}`).show()
@@ -267,6 +263,7 @@ function add_new_text_cell(c_id, where) {
267263
document.getElementById(`btn-actions-${new_id}`).style.display = "none"
268264
});
269265

266+
270267
}
271268

272269
function delete_cell(id) {
@@ -295,7 +292,6 @@ $(document).on("click", "button.run", function () {
295292
}
296293
})
297294

298-
299295
$(document).on("click", "button.del", function () {
300296
let id = this.id.split("_")[1]
301297
console.log(id, this.id, __code_cell_count)
@@ -338,7 +334,6 @@ function show_md(id, value) {
338334
document.getElementById(div_id).style.display = "none"
339335
}
340336

341-
342337
$(document).on("dblclick", "div.text-out-box", function () {
343338
let id = this.id.split("_")[1]
344339
md_id = `text-div_${id}`

notebookjs/src/public/javascripts/utils.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,15 @@ function load_notebook(json) {
304304
$(`#btn-actions-${id}`).hide()
305305
});
306306

307+
$(`#div-${id}`).keydown(function (e) {
308+
if ((e.ctrlKey || e.metaKey) && (e.keyCode == 13 || e.keyCode == 10)) {
309+
// document.getElementById("cell_spinner-1").style.display = "block"
310+
// document.getElementById("cell_num-1").style.display = "none"
311+
exec_cell(`run_div-${id}`);
312+
313+
}
314+
});
315+
307316
} else {
308317

309318
let md = md_load(id)

0 commit comments

Comments
 (0)