Skip to content

Commit 7563c54

Browse files
author
Onno Broekmans
authored
Fix broken "Raw cell MIME type" dialog (#3255) (#5385)
The modal dialog for entering a custom MIME type for a "Raw NBConvert"- type cell was broken. This change to the JavaScript code makes the modal dialog appear correctly again, as well as correctly disabling the handling of key presses by the cell editor while the dialog is open. This fixes #3255.
1 parent 4775ee5 commit 7563c54

File tree

1 file changed

+28
-13
lines changed
  • notebook/static/notebook/js/celltoolbarpresets

1 file changed

+28
-13
lines changed

notebook/static/notebook/js/celltoolbarpresets/rawcell.js

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,35 @@ define([
2626
function(cell, value) {
2727
if (value === "-") {
2828
delete cell.metadata.raw_mimetype;
29-
} else if (value === 'dialog'){
30-
var dialog = $('<div/>').append(
31-
$("<p/>")
32-
.text(i18n.msg._("Set the MIME type of the raw cell:"))
33-
).append(
34-
$("<br/>")
35-
).append(
36-
$('<input/>').attr('type','text').attr('size','25')
37-
.val(cell.metadata.raw_mimetype || "-")
38-
);
29+
} else if (value === 'dialog') {
30+
var message =
31+
i18n.msg._("Set the MIME type of the raw cell:");
32+
33+
var mimeinput = $('<input/>')
34+
.attr('type', 'text')
35+
.attr('size', '25')
36+
.attr('name', 'mimetype')
37+
.val(cell.metadata.raw_mimetype || "-");
38+
39+
var dialogform = $('<div/>').attr('title', i18n.msg._("Edit MIME type"))
40+
.append(
41+
$('<form/>').append(
42+
$('<fieldset/>').append(
43+
$('<label/>')
44+
.attr('for', 'mimetype')
45+
.text(message)
46+
)
47+
.append($('<br/>'))
48+
.append(mimeinput)
49+
)
50+
);
51+
3952
dialog.modal({
4053
title: i18n.msg._("Raw Cell MIME Type"),
41-
body: dialog,
54+
body: dialogform,
4255
buttons : {
43-
"Cancel": {},
44-
"OK": {
56+
Cancel: {},
57+
OK: {
4558
class: "btn-primary",
4659
click: function () {
4760
console.log(cell);
@@ -50,6 +63,8 @@ define([
5063
}
5164
}
5265
},
66+
notebook: cell.notebook,
67+
keyboard_manager: cell.keyboard_manager,
5368
open : function (event, ui) {
5469
var that = $(this);
5570
// Upon ENTER, click the OK button.

0 commit comments

Comments
 (0)