Skip to content

Commit f1e62ab

Browse files
committed
fix run button for md cell
1 parent f8c7d9e commit f1e62ab

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

  • notebookjs/src/public/javascripts

notebookjs/src/public/javascripts/index.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function add_new_text_cell(c_id, where) {
154154
155155
<div id="text-div_${new_id}" class="col-md-11">
156156
<div id="btn-actions-${new_id}" class="btn-group-horizontal" style="margin-bottom: 2px;">
157-
<button type="button" id="run_div-1" class="btn btn-sm btn-success run"><i class="fas fa-play"></i>
157+
<button type="button" id="run_md_div-${new_id}" class="btn btn-sm btn-success run"><i class="fas fa-play"></i>
158158
Run</button>
159159
<div class="btn-group" role="group" aria-label="Basic example">
160160
<button type="button" id="add_code_down_btn-${new_id}" class="btn btn-sm btn-info add-code">
@@ -241,7 +241,14 @@ function delete_text_cell(id) {
241241

242242

243243
$(document).on("click", "button.run", function () {
244-
exec_cell(this.id);
244+
if (this.id.split("_").includes("md")) {
245+
console.log("md");
246+
let id = this.id.split("-")[1]
247+
let val = document.getElementById(`text-box_${id}`).value
248+
show_md(id, val)
249+
} else {
250+
exec_cell(this.id);
251+
}
245252
})
246253

247254
$(document).on("click", "button.del", function () {
@@ -273,13 +280,17 @@ $(document).on("click", "button.add-text", function () {
273280

274281
$(document).on("dblclick", "textarea.text-box", function () {
275282
let id = this.id.split("_")[1]
283+
show_md(id, this.value)
284+
285+
})
286+
287+
function show_md(id, value) {
276288
div_id = `text-div_${id}`
277-
md_texts[div_id] = this.value //stores the markdown text for the corresponding div
278-
render_md = md.render(this.value)
289+
md_texts[div_id] = value //stores the markdown text for the corresponding div
290+
render_md = md.render(value)
279291
$(`#out-text-div_${id}`).html(render_md).show()
280292
document.getElementById(div_id).style.display = "none"
281-
282-
})
293+
}
283294

284295
$(document).on("dblclick", "div.text-out-box", function () {
285296
let id = this.id.split("_")[1]

0 commit comments

Comments
 (0)