Fixed embedded version of jsoneditor ace theme not being loaded in minimalist version. Added docs and example on loading a custom Ace editor (see #55)
This commit is contained in:
parent
4bc339f6fe
commit
8dc4752872
|
@ -3,6 +3,13 @@
|
|||
https://github.com/josdejong/jsoneditor
|
||||
|
||||
|
||||
## (not yet released), version 5.5.11
|
||||
|
||||
- Fixed embedded version of jsoneditor ace theme not being loaded in
|
||||
minimalist version (see #55).
|
||||
- Added docs and example on how to use a custom version of Ace editor.
|
||||
|
||||
|
||||
## 2016-11-02, version 5.5.10
|
||||
|
||||
- Fixed #85: pressing enter in an input in a form containing a JSONEditor too
|
||||
|
|
|
@ -35,6 +35,8 @@ Constructs a new JSONEditor.
|
|||
|
||||
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`.
|
||||
|
||||
Note that when using the minimalist version of JSONEditor (which has Ace excluded), JSONEditor will try to load the Ace plugins `ace/mode/json` and `ace/ext/searchbox`. These plugins must be loaded beforehand or be available in the folder of the Ace editor.
|
||||
|
||||
- `{Object} ajv`
|
||||
|
||||
Provide a custom instance of [ajv](https://github.com/epoberezkin/ajv), the
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>JSONEditor | Custom Ace</title>
|
||||
|
||||
<!-- load a custom version of Ace editor -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js"></script>
|
||||
|
||||
<!-- load the minimalist version of JSONEditor, which doesn't have Ace embedded -->
|
||||
<link href="../dist/jsoneditor.css" rel="stylesheet" type="text/css">
|
||||
<script src="../dist/jsoneditor-minimalist.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
#jsoneditor {
|
||||
width: 500px;
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
body, html {
|
||||
font-family: "DejaVu Sans", sans-serif;
|
||||
}
|
||||
|
||||
p, li {
|
||||
width: 500px;
|
||||
font-size: 10.5pt;
|
||||
}
|
||||
|
||||
code {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1>Custom Ace editor</h1>
|
||||
<p>
|
||||
This example demonstrates how to load a custom version of Ace editor into JSONEditor.
|
||||
</p>
|
||||
<p>
|
||||
By default, JSONEditor <code>code</code> mode loads the following Ace plugins:
|
||||
</p>
|
||||
<ul>
|
||||
<li>ace/mode/json</li>
|
||||
<li>ace/ext/searchbox</li>
|
||||
<li>ace/theme/jsoneditor</li>
|
||||
</ul>
|
||||
<p>
|
||||
The jsoneditor theme comes embedded with JSONEditor. The other two plugins (json and searchbox) must be available in the folder of the custom Ace editor, or already be loaded via a script tag.
|
||||
</p>
|
||||
|
||||
<div id="jsoneditor"></div>
|
||||
|
||||
<script>
|
||||
// create the editor
|
||||
var container = document.getElementById('jsoneditor');
|
||||
var options = {
|
||||
modes: ['text', 'code', 'tree', 'form', 'view'],
|
||||
mode: 'code',
|
||||
ace: ace
|
||||
};
|
||||
var json = {
|
||||
'array': [1, 2, 3],
|
||||
'boolean': true,
|
||||
'null': null,
|
||||
'number': 123,
|
||||
'object': {'a': 'b', 'c': 'd'},
|
||||
'string': 'Hello World'
|
||||
};
|
||||
var editor = new JSONEditor(container, options, json);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -84,7 +84,7 @@ function minify(name) {
|
|||
gutil.log('Mapped ' + fileMap);
|
||||
}
|
||||
|
||||
// make dist and dist/img folders
|
||||
// make dist folder structure
|
||||
gulp.task('mkdir', function () {
|
||||
mkdirp.sync(DIST);
|
||||
mkdirp.sync(DIST + '/img');
|
||||
|
@ -144,7 +144,7 @@ gulp.task('bundle-css', ['mkdir'], function () {
|
|||
// create a folder img and copy the icons
|
||||
gulp.task('copy-img', ['mkdir'], function () {
|
||||
gulp.src(IMAGE)
|
||||
.pipe(gulp.dest(DIST +'/img'));
|
||||
.pipe(gulp.dest(DIST + '/img'));
|
||||
gutil.log('Copied images');
|
||||
});
|
||||
|
||||
|
|
|
@ -4,6 +4,5 @@ var ace = require('brace');
|
|||
// load required ace modules
|
||||
require('brace/mode/json');
|
||||
require('brace/ext/searchbox');
|
||||
require('./theme-jsoneditor');
|
||||
|
||||
module.exports = ace;
|
||||
|
|
|
@ -16,6 +16,8 @@ var textmode = {};
|
|||
|
||||
var MAX_ERRORS = 3; // maximum number of displayed errors at the bottom
|
||||
|
||||
var DEFAULT_THEME = 'ace/theme/jsoneditor';
|
||||
|
||||
/**
|
||||
* Create a text editor
|
||||
* @param {Element} container
|
||||
|
@ -63,7 +65,10 @@ textmode.create = function (container, options) {
|
|||
}
|
||||
|
||||
// determine theme
|
||||
this.theme = options.theme || 'ace/theme/jsoneditor';
|
||||
this.theme = options.theme || DEFAULT_THEME;
|
||||
if (this.theme === DEFAULT_THEME) {
|
||||
require('./ace/theme-jsoneditor');
|
||||
}
|
||||
|
||||
var me = this;
|
||||
this.container = container;
|
||||
|
|
Loading…
Reference in New Issue