Merge pull request #2699 from takluyver/i1976

Validate CodeMirror keyMap from frontend config
This commit is contained in:
Grant Nestor 2017-07-27 09:10:10 -07:00 committed by GitHub
commit 97d1730bdc

View File

@ -87,6 +87,7 @@ define([
*/
function Notebook(selector, options) {
this.config = options.config;
this.config.loaded.then(this.validate_config.bind(this))
this.class_config = new configmod.ConfigWithDefaults(this.config,
Notebook.options_default, 'Notebook');
this.base_url = options.base_url;
@ -259,6 +260,15 @@ define([
Toolbar: true
};
Notebook.prototype.validate_config = function() {
var code_cell = this.config.data['CodeCell'] || {};
var cm_keymap = (code_cell['cm_config'] || {})['keyMap'];
if (cm_keymap && CodeMirror.keyMap[cm_keymap] === undefined) {
console.warn('CodeMirror keymap not found, ignoring: ' + cm_keymap);
delete code_cell.cm_config.keyMap;
}
};
/**
* Create an HTML and CSS representation of the notebook.
*/