Merge pull request #170 from nfvs/custom_themes

Support for custom themes.
This commit is contained in:
Jos de Jong 2015-03-18 21:43:18 +01:00
commit 99c52e044d
2 changed files with 4 additions and 1 deletions

View File

@ -34,6 +34,8 @@ Constructs a new JSONEditor.
Enables a search box in the upper right corner of the JSONEditor. True by default. Only applicable when `mode` is 'tree', 'view', or 'form'. Enables a search box in the upper right corner of the JSONEditor. True by default. Only applicable when `mode` is 'tree', 'view', or 'form'.
- `{Number} indentation` - `{Number} indentation`
Number of indentation spaces. 2 by default. Only applicable when `mode` is 'code' or 'text'. Number of indentation spaces. 2 by default. Only applicable when `mode` is 'code' or 'text'.
- `{String} theme`
Set the Ace editor theme, uses included 'ace/theme/jsoneditor' by default. Please note that only the default theme is included with jsoneditor, so if you specify another one you need to make sure it is loaded.
- `{JSON} json` - `{JSON} json`
Initial JSON data to be loaded into the JSONEditor. Alternatively, the method `JSONEditor.set(json)` can be used to load JSON data into the editor. Initial JSON data to be loaded into the JSONEditor. Alternatively, the method `JSONEditor.set(json)` can be used to load JSON data into the editor.

View File

@ -44,6 +44,7 @@ textmode.create = function (container, options) {
'Falling back to plain text editor'); 'Falling back to plain text editor');
} }
} }
this.theme = options.theme || 'ace/theme/jsoneditor';
var me = this; var me = this;
this.container = container; this.container = container;
@ -117,7 +118,7 @@ textmode.create = function (container, options) {
this.content.appendChild(this.editorDom); this.content.appendChild(this.editorDom);
var editor = ace.edit(this.editorDom); var editor = ace.edit(this.editorDom);
editor.setTheme('ace/theme/jsoneditor'); editor.setTheme(this.theme);
editor.setShowPrintMargin(false); editor.setShowPrintMargin(false);
editor.setFontSize(13); editor.setFontSize(13);
editor.getSession().setMode('ace/mode/json'); editor.getSession().setMode('ace/mode/json');