mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
Merge pull request #7438 from minrk/auto_highlight
move auto_highlight to Cell
This commit is contained in:
commit
1eb04fd583
@ -516,7 +516,15 @@ define([
|
||||
this.user_highlight = mode;
|
||||
this.auto_highlight();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Trigger autodetection of highlight scheme for current cell
|
||||
* @method auto_highlight
|
||||
*/
|
||||
Cell.prototype.auto_highlight = function () {
|
||||
this._auto_highlight(this.class_config.get_sync('highlight_modes'));
|
||||
};
|
||||
|
||||
/**
|
||||
* Try to autodetect cell highlight mode, or use selected mode
|
||||
* @methods _auto_highlight
|
||||
@ -655,7 +663,7 @@ define([
|
||||
var cell = this;
|
||||
|
||||
this.element.find('.inner_cell').find("a").click(function () {
|
||||
cell.events.trigger('unrecognized_cell.Cell', {cell: cell})
|
||||
cell.events.trigger('unrecognized_cell.Cell', {cell: cell});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -147,7 +147,7 @@ define([
|
||||
};
|
||||
|
||||
CodeCell.config_defaults = {
|
||||
cell_magic_highlight : {
|
||||
highlight_modes : {
|
||||
'magic_javascript' :{'reg':[/^%%javascript/]},
|
||||
'magic_perl' :{'reg':[/^%%perl/]},
|
||||
'magic_ruby' :{'reg':[/^%%ruby/]},
|
||||
@ -179,13 +179,6 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @method auto_highlight
|
||||
*/
|
||||
CodeCell.prototype.auto_highlight = function () {
|
||||
this._auto_highlight(this.class_config.get_sync('cell_magic_highlight'));
|
||||
};
|
||||
|
||||
/** @method create_element */
|
||||
CodeCell.prototype.create_element = function () {
|
||||
Cell.prototype.create_element.apply(this, arguments);
|
||||
@ -202,7 +195,7 @@ define([
|
||||
inner_cell.append(this.celltoolbar.element);
|
||||
var input_area = $('<div/>').addClass('input_area');
|
||||
this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config);
|
||||
this.code_mirror.on('keydown', $.proxy(this.handle_keyevent,this))
|
||||
this.code_mirror.on('keydown', $.proxy(this.handle_keyevent,this));
|
||||
$(this.code_mirror.getInputField()).attr("spellcheck", "false");
|
||||
inner_cell.append(input_area);
|
||||
input.append(prompt).append(inner_cell);
|
||||
|
@ -340,14 +340,6 @@ define([
|
||||
this.code_mirror.on('focus', function() { that.unrender(); });
|
||||
};
|
||||
|
||||
/**
|
||||
* Trigger autodetection of highlight scheme for current cell
|
||||
* @method auto_highlight
|
||||
*/
|
||||
RawCell.prototype.auto_highlight = function () {
|
||||
this._auto_highlight(this.class_config.get_sync('highlight_modes'));
|
||||
};
|
||||
|
||||
/** @method render **/
|
||||
RawCell.prototype.render = function () {
|
||||
var cont = TextCell.prototype.render.apply(this);
|
||||
@ -356,6 +348,7 @@ define([
|
||||
if (text === "") { text = this.placeholder; }
|
||||
this.set_text(text);
|
||||
this.element.removeClass('rendered');
|
||||
this.auto_highlight();
|
||||
}
|
||||
return cont;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user