mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-18 11:55:46 +08:00
Merge pull request #2699 from takluyver/i1976
Validate CodeMirror keyMap from frontend config
This commit is contained in:
commit
97d1730bdc
@ -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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user