Merge pull request #8045 from Carreau/cmconfigmerge

Merge codemirror config with user config.
This commit is contained in:
Thomas Kluyver 2015-03-16 14:40:45 -07:00
commit 05d5b586e5
3 changed files with 9 additions and 6 deletions

View File

@ -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 _local_cm_config = {};
if(this.class_config){
_local_cm_config = this.class_config.get_sync('cm_config');
}
this.cm_config = utils.mergeopt({}, config.cm_config, _local_cm_config);
this.cell_id = utils.uuid();
this._options = config;

View File

@ -163,7 +163,7 @@ define([
notebook: this.notebook});
inner_cell.append(this.celltoolbar.element);
var input_area = $('<div/>').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 () {

View File

@ -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';
};