From f029025fbc20a64d783edacc8d625e8c507222a4 2015-03-13 20:40:44 From: Matthias Bussonnier Date: 2015-03-13 20:40:44 Subject: [PATCH] Merge codemirror config with user config. Simplify customisation of codemirror without duplicating the all codecell configuration. Closes #8038 --- diff --git a/IPython/html/static/notebook/js/cell.js b/IPython/html/static/notebook/js/cell.js index aff28c1..8e07e46 100644 --- a/IPython/html/static/notebook/js/cell.js +++ b/IPython/html/static/notebook/js/cell.js @@ -56,7 +56,6 @@ define([ // superclass default overwrite our default this.placeholder = config.placeholder || ''; - this.read_only = config.cm_config.readOnly; this.selected = false; this.rendered = false; this.mode = 'command'; @@ -76,7 +75,12 @@ define([ // load this from metadata later ? this.user_highlight = 'auto'; - this.cm_config = config.cm_config; + + var class_conf_value = {}; + if(this.class_config){ + class_conf_value = this.class_config.get_sync('cm_config'); + } + this.cm_config = utils.mergeopt({}, config.cm_config, class_conf_value); this.cell_id = utils.uuid(); this._options = config; diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index 4cfaf85..909c5c7 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -163,7 +163,7 @@ define([ notebook: this.notebook}); inner_cell.append(this.celltoolbar.element); var input_area = $('
').addClass('input_area'); - this.code_mirror = new CodeMirror(input_area.get(0), this.class_config.get_sync('cm_config')); + this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config); // In case of bugs that put the keyboard manager into an inconsistent state, // ensure KM is enabled when CodeMirror is focused: this.code_mirror.on('focus', function () { diff --git a/IPython/html/static/notebook/js/textcell.js b/IPython/html/static/notebook/js/textcell.js index 8046c41..ff9f1f3 100644 --- a/IPython/html/static/notebook/js/textcell.js +++ b/IPython/html/static/notebook/js/textcell.js @@ -129,7 +129,6 @@ define([ }; TextCell.prototype.unrender = function () { - if (this.read_only) return; var cont = Cell.prototype.unrender.apply(this); if (cont) { var text_cell = this.element; @@ -230,10 +229,10 @@ define([ */ options = options || {}; var config = utils.mergeopt(MarkdownCell, {}); - TextCell.apply(this, [$.extend({}, options, {config: config})]); - this.class_config = new configmod.ConfigWithDefaults(options.config, {}, 'MarkdownCell'); + TextCell.apply(this, [$.extend({}, options, {config: config})]); + this.cell_type = 'markdown'; };