From 63a4a764f26c61e61220a8a37fff71e4f5dda071 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Fri, 13 Mar 2015 13:40:44 -0700 Subject: [PATCH 1/3] Merge codemirror config with user config. Simplify customisation of codemirror without duplicating the all codecell configuration. Closes #8038 --- IPython/html/static/notebook/js/cell.js | 8 ++++++-- IPython/html/static/notebook/js/codecell.js | 2 +- IPython/html/static/notebook/js/textcell.js | 5 ++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/IPython/html/static/notebook/js/cell.js b/IPython/html/static/notebook/js/cell.js index aff28c19d..8e07e469f 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 4cfaf85b2..909c5c73c 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 8046c41cf..ff9f1f323 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'; }; From 025ec6df772de9ca9a17cf813315b386ae0e9fa3 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Fri, 13 Mar 2015 14:37:38 -0700 Subject: [PATCH 2/3] Rename local variable to avoid confusion. --- IPython/html/static/notebook/js/cell.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IPython/html/static/notebook/js/cell.js b/IPython/html/static/notebook/js/cell.js index 8e07e469f..32a671e28 100644 --- a/IPython/html/static/notebook/js/cell.js +++ b/IPython/html/static/notebook/js/cell.js @@ -29,7 +29,7 @@ define([ // Reverse `min-height: 18px` scrollbar hack on OS X // which causes a dead area, making it impossible to click on the last line // when there is horizontal scrolling to do and the "show scrollbar only when scrolling" behavior - // is enabled. + // is enabled.c // This, in turn, has the undesirable behavior of never showing the horizontal scrollbar, // even when it should, which is less problematic, at least. if (/Mac/.test(navigator.platform)) { @@ -76,11 +76,11 @@ define([ // load this from metadata later ? this.user_highlight = 'auto'; - var class_conf_value = {}; + var _local_cm_config = {}; if(this.class_config){ - class_conf_value = this.class_config.get_sync('cm_config'); + _local_cm_config = this.class_config.get_sync('cm_config'); } - this.cm_config = utils.mergeopt({}, config.cm_config, class_conf_value); + this.cm_config = utils.mergeopt({}, config.cm_config, _local_cm_config); this.cell_id = utils.uuid(); this._options = config; From bfc45392f851cbabcd9d527d6abeea2735a5f6fa Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Mon, 16 Mar 2015 14:23:04 -0700 Subject: [PATCH 3/3] remove Stray .c --- IPython/html/static/notebook/js/cell.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IPython/html/static/notebook/js/cell.js b/IPython/html/static/notebook/js/cell.js index 32a671e28..dda60e3d6 100644 --- a/IPython/html/static/notebook/js/cell.js +++ b/IPython/html/static/notebook/js/cell.js @@ -29,7 +29,7 @@ define([ // Reverse `min-height: 18px` scrollbar hack on OS X // which causes a dead area, making it impossible to click on the last line // when there is horizontal scrolling to do and the "show scrollbar only when scrolling" behavior - // is enabled.c + // is enabled. // This, in turn, has the undesirable behavior of never showing the horizontal scrollbar, // even when it should, which is less problematic, at least. if (/Mac/.test(navigator.platform)) {