This commit is contained in:
parent
7c62f5a97d
commit
a7f41b8ef5
|
@ -7,6 +7,8 @@ https://github.com/josdejong/jsoneditor
|
||||||
|
|
||||||
- Implemented option `theme`, allowing to set a custom theme for the Ace
|
- Implemented option `theme`, allowing to set a custom theme for the Ace
|
||||||
editor. Thanks @nfvs.
|
editor. Thanks @nfvs.
|
||||||
|
- Implemented option `ace`, which allows to pass a custom instance of the Ace
|
||||||
|
instead of the embedded version.
|
||||||
- Fixed #186: binding issue to `jsonlint.parse`.
|
- Fixed #186: binding issue to `jsonlint.parse`.
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -15,6 +15,8 @@ Constructs a new JSONEditor.
|
||||||
- `{Object} options`
|
- `{Object} options`
|
||||||
Optional object with options. Available options:
|
Optional object with options. Available options:
|
||||||
|
|
||||||
|
- `{Object} ace`
|
||||||
|
Provide a custom version of the [Ace editor](http://ace.c9.io/) and use this instead of the version that comes embedded with JSONEditor. Only applicable when `mode` is `code`.
|
||||||
- `{function} change`
|
- `{function} change`
|
||||||
Set a callback method triggered when the contents of the JSONEditor change. Called without parameters. Will only be triggered on changes made by the user, not in case of programmatic changes via the functions `set` or `setText`.
|
Set a callback method triggered when the contents of the JSONEditor change. Called without parameters. Will only be triggered on changes made by the user, not in case of programmatic changes via the functions `set` or `setText`.
|
||||||
- `{function} editable`
|
- `{function} editable`
|
||||||
|
|
|
@ -23,22 +23,31 @@ var textmode = {};
|
||||||
* spaces. 2 by default.
|
* spaces. 2 by default.
|
||||||
* {function} change Callback method
|
* {function} change Callback method
|
||||||
* triggered on change
|
* triggered on change
|
||||||
|
* {Object} ace A custom instance of
|
||||||
|
* Ace editor.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
textmode.create = function (container, options) {
|
textmode.create = function (container, options) {
|
||||||
// read options
|
// read options
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
|
// indentation
|
||||||
if (options.indentation) {
|
if (options.indentation) {
|
||||||
this.indentation = Number(options.indentation);
|
this.indentation = Number(options.indentation);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.indentation = 2; // number of spaces
|
this.indentation = 2; // number of spaces
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// grab ace from options if provided
|
||||||
|
var _ace = options.ace ? options.ace : ace;
|
||||||
|
|
||||||
|
// determine mode
|
||||||
this.mode = (options.mode == 'code') ? 'code' : 'text';
|
this.mode = (options.mode == 'code') ? 'code' : 'text';
|
||||||
if (this.mode == 'code') {
|
if (this.mode == 'code') {
|
||||||
// verify whether Ace editor is available and supported
|
// verify whether Ace editor is available and supported
|
||||||
if (typeof ace === 'undefined') {
|
if (typeof _ace === 'undefined') {
|
||||||
this.mode = 'text';
|
this.mode = 'text';
|
||||||
util.log('WARNING: Cannot load code editor, Ace library not loaded. ' +
|
util.log('WARNING: Cannot load code editor, Ace library not loaded. ' +
|
||||||
'Falling back to plain text editor');
|
'Falling back to plain text editor');
|
||||||
|
@ -117,7 +126,7 @@ textmode.create = function (container, options) {
|
||||||
this.editorDom.style.width = '100%'; // TODO: move to css
|
this.editorDom.style.width = '100%'; // TODO: move to css
|
||||||
this.content.appendChild(this.editorDom);
|
this.content.appendChild(this.editorDom);
|
||||||
|
|
||||||
var editor = ace.edit(this.editorDom);
|
var editor = _ace.edit(this.editorDom);
|
||||||
editor.setTheme(this.theme);
|
editor.setTheme(this.theme);
|
||||||
editor.setShowPrintMargin(false);
|
editor.setShowPrintMargin(false);
|
||||||
editor.setFontSize(13);
|
editor.setFontSize(13);
|
||||||
|
|
Loading…
Reference in New Issue