Using brace to load Ace. Ace and jsonlint are now packed by default with JSONEditor. Removed all redundant build stuff for the assets.

This commit is contained in:
jos 2015-02-27 21:54:04 +01:00
parent c18145f503
commit 0db2c35c2b
29 changed files with 20344 additions and 604 deletions

View File

@ -3,6 +3,12 @@
https://github.com/josdejong/jsoneditor https://github.com/josdejong/jsoneditor
## not yet released, version 4.0.0
- Ace editor and jsonlint are now packed with jsoneditor.js by default.
- Reworked the source code to CommonJS modules, using `brace` to load Ace.
## 2015-01-25, version 3.2.0 ## 2015-01-25, version 3.2.0
- Implemented shortcut keys `Ctrl+\` to format and `Ctrl+Shift+\` to compact - Implemented shortcut keys `Ctrl+\` to format and `Ctrl+Shift+\` to compact

View File

@ -74,12 +74,12 @@ download:
<html> <html>
<head> <head>
<link rel="stylesheet" type="text/css" href="jsoneditor/jsoneditor.min.css"> <link rel="stylesheet" type="text/css" href="jsoneditor/jsoneditor.min.css">
<script type="text/javascript" src="jsoneditor/jsoneditor.min.js"></script> <script src="jsoneditor/jsoneditor.min.js"></script>
</head> </head>
<body> <body>
<div id="jsoneditor" style="width: 400px; height: 400px;"></div> <div id="jsoneditor" style="width: 400px; height: 400px;"></div>
<script type="text/javascript" > <script>
// create the editor // create the editor
var container = document.getElementById("jsoneditor"); var container = document.getElementById("jsoneditor");
var editor = new JSONEditor(container); var editor = new JSONEditor(container);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,144 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define('ace/theme/jsoneditor', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
exports.isDark = false;
exports.cssClass = "ace-jsoneditor";
exports.cssText = ".ace-jsoneditor .ace_gutter {\
background: #ebebeb;\
color: #333\
}\
\
.ace-jsoneditor.ace_editor {\
font-family: droid sans mono, monospace, courier new, courier, sans-serif;\
line-height: 1.3;\
}\
.ace-jsoneditor .ace_print-margin {\
width: 1px;\
background: #e8e8e8\
}\
.ace-jsoneditor .ace_scroller {\
background-color: #FFFFFF\
}\
.ace-jsoneditor .ace_text-layer {\
color: gray\
}\
.ace-jsoneditor .ace_variable {\
color: #1a1a1a\
}\
.ace-jsoneditor .ace_cursor {\
border-left: 2px solid #000000\
}\
.ace-jsoneditor .ace_overwrite-cursors .ace_cursor {\
border-left: 0px;\
border-bottom: 1px solid #000000\
}\
.ace-jsoneditor .ace_marker-layer .ace_selection {\
background: #D5DDF6\
}\
.ace-jsoneditor.ace_multiselect .ace_selection.ace_start {\
box-shadow: 0 0 3px 0px #FFFFFF;\
border-radius: 2px\
}\
.ace-jsoneditor .ace_marker-layer .ace_step {\
background: rgb(255, 255, 0)\
}\
.ace-jsoneditor .ace_marker-layer .ace_bracket {\
margin: -1px 0 0 -1px;\
border: 1px solid #BFBFBF\
}\
.ace-jsoneditor .ace_marker-layer .ace_active-line {\
background: #FFFBD1\
}\
.ace-jsoneditor .ace_gutter-active-line {\
background-color : #dcdcdc\
}\
.ace-jsoneditor .ace_marker-layer .ace_selected-word {\
border: 1px solid #D5DDF6\
}\
.ace-jsoneditor .ace_invisible {\
color: #BFBFBF\
}\
.ace-jsoneditor .ace_keyword,\
.ace-jsoneditor .ace_meta,\
.ace-jsoneditor .ace_support.ace_constant.ace_property-value {\
color: #AF956F\
}\
.ace-jsoneditor .ace_keyword.ace_operator {\
color: #484848\
}\
.ace-jsoneditor .ace_keyword.ace_other.ace_unit {\
color: #96DC5F\
}\
.ace-jsoneditor .ace_constant.ace_language {\
color: darkorange\
}\
.ace-jsoneditor .ace_constant.ace_numeric {\
color: red\
}\
.ace-jsoneditor .ace_constant.ace_character.ace_entity {\
color: #BF78CC\
}\
.ace-jsoneditor .ace_invalid {\
color: #FFFFFF;\
background-color: #FF002A;\
}\
.ace-jsoneditor .ace_fold {\
background-color: #AF956F;\
border-color: #000000\
}\
.ace-jsoneditor .ace_storage,\
.ace-jsoneditor .ace_support.ace_class,\
.ace-jsoneditor .ace_support.ace_function,\
.ace-jsoneditor .ace_support.ace_other,\
.ace-jsoneditor .ace_support.ace_type {\
color: #C52727\
}\
.ace-jsoneditor .ace_string {\
color: green\
}\
.ace-jsoneditor .ace_comment {\
color: #BCC8BA\
}\
.ace-jsoneditor .ace_entity.ace_name.ace_tag,\
.ace-jsoneditor .ace_entity.ace_other.ace_attribute-name {\
color: #606060\
}\
.ace-jsoneditor .ace_markup.ace_underline {\
text-decoration: underline\
}\
.ace-jsoneditor .ace_indent-guide {\
background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y\
}";
var dom = require("../lib/dom");
dom.importCssString(exports.cssText, exports.cssClass);
});

View File

@ -1 +0,0 @@
define("ace/theme/textmate",["require","exports","module","ace/lib/dom"],function(e,t,n){t.isDark=!1,t.cssClass="ace-tm",t.cssText='.ace-tm .ace_gutter {background: #f0f0f0;color: #333;}.ace-tm .ace_print-margin {width: 1px;background: #e8e8e8;}.ace-tm .ace_fold {background-color: #6B72E6;}.ace-tm {background-color: #FFFFFF;color: black;}.ace-tm .ace_cursor {color: black;}.ace-tm .ace_invisible {color: rgb(191, 191, 191);}.ace-tm .ace_storage,.ace-tm .ace_keyword {color: blue;}.ace-tm .ace_constant {color: rgb(197, 6, 11);}.ace-tm .ace_constant.ace_buildin {color: rgb(88, 72, 246);}.ace-tm .ace_constant.ace_language {color: rgb(88, 92, 246);}.ace-tm .ace_constant.ace_library {color: rgb(6, 150, 14);}.ace-tm .ace_invalid {background-color: rgba(255, 0, 0, 0.1);color: red;}.ace-tm .ace_support.ace_function {color: rgb(60, 76, 114);}.ace-tm .ace_support.ace_constant {color: rgb(6, 150, 14);}.ace-tm .ace_support.ace_type,.ace-tm .ace_support.ace_class {color: rgb(109, 121, 222);}.ace-tm .ace_keyword.ace_operator {color: rgb(104, 118, 135);}.ace-tm .ace_string {color: rgb(3, 106, 7);}.ace-tm .ace_comment {color: rgb(76, 136, 107);}.ace-tm .ace_comment.ace_doc {color: rgb(0, 102, 255);}.ace-tm .ace_comment.ace_doc.ace_tag {color: rgb(128, 159, 191);}.ace-tm .ace_constant.ace_numeric {color: rgb(0, 0, 205);}.ace-tm .ace_variable {color: rgb(49, 132, 149);}.ace-tm .ace_xml-pe {color: rgb(104, 104, 91);}.ace-tm .ace_entity.ace_name.ace_function {color: #0000A2;}.ace-tm .ace_heading {color: rgb(12, 7, 255);}.ace-tm .ace_list {color:rgb(185, 6, 144);}.ace-tm .ace_meta.ace_tag {color:rgb(0, 22, 142);}.ace-tm .ace_string.ace_regex {color: rgb(255, 0, 0)}.ace-tm .ace_marker-layer .ace_selection {background: rgb(181, 213, 255);}.ace-tm.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px white;border-radius: 2px;}.ace-tm .ace_marker-layer .ace_step {background: rgb(252, 255, 0);}.ace-tm .ace_marker-layer .ace_stack {background: rgb(164, 229, 101);}.ace-tm .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid rgb(192, 192, 192);}.ace-tm .ace_marker-layer .ace_active-line {background: rgba(0, 0, 0, 0.07);}.ace-tm .ace_gutter-active-line {background-color : #dcdcdc;}.ace-tm .ace_marker-layer .ace_selected-word {background: rgb(250, 250, 255);border: 1px solid rgb(200, 200, 250);}.ace-tm .ace_indent-guide {background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y;}';var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass)})

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -24,30 +24,7 @@ in the head of the HTML page:
```html ```html
<link rel="stylesheet" type="text/css" href="jsoneditor/jsoneditor.min.css"> <link rel="stylesheet" type="text/css" href="jsoneditor/jsoneditor.min.css">
<script type="text/javascript" src="jsoneditor/jsoneditor.min.js"></script> <script src="jsoneditor/jsoneditor.min.js"></script>
```
### Detailed error messages
Optionally, [jsonlint](https://github.com/zaach/jsonlint) can be loaded to get
more detailed error messages.
```html
<script type="text/javascript" src="jsoneditor/asset/jsonlint/jsonlint.js"></script>
```
### Code editor
The mode 'code' requires the [Ace editor](http://ace.ajax.org/) to be loaded.
JSON Editor comes with a custom built version of Ace containing the ace modules
`ace.js`, `ext-searchbox.js`, `mode-json.js`, `theme-textmate.js`, and a custom
theme `theme-jsoneditor.js`.
Besides loading ace, the content type must be specified on the page.
```html
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script type="text/javascript" src="jsoneditor/asset/ace/ace.js"></script>
``` ```
## Use ## Use
@ -96,7 +73,7 @@ var json = editor.get();
<html> <html>
<head> <head>
<link rel="stylesheet" type="text/css" href="jsoneditor/jsoneditor.min.css"> <link rel="stylesheet" type="text/css" href="jsoneditor/jsoneditor.min.css">
<script type="text/javascript" src="jsoneditor/jsoneditor.min.js"></script> <script src="jsoneditor/jsoneditor.min.js"></script>
</head> </head>
<body> <body>
<p> <p>
@ -105,7 +82,7 @@ var json = editor.get();
</p> </p>
<div id="jsoneditor" style="width: 400px; height: 400px;"></div> <div id="jsoneditor" style="width: 400px; height: 400px;"></div>
<script type="text/javascript" > <script>
// create the editor // create the editor
var container = document.getElementById("jsoneditor"); var container = document.getElementById("jsoneditor");
var editor = new JSONEditor(container); var editor = new JSONEditor(container);

View File

@ -2,8 +2,10 @@
<html> <html>
<head> <head>
<title>JSONEditor | Basic usage</title> <title>JSONEditor | Basic usage</title>
<link rel="stylesheet" type="text/css" href="../jsoneditor.css"> <link rel="stylesheet" type="text/css" href="../jsoneditor.css">
<script type="text/javascript" src="../jsoneditor.js"></script> <script src="../jsoneditor.js"></script>
<style type="text/css"> <style type="text/css">
#jsoneditor { #jsoneditor {
width: 500px; width: 500px;
@ -18,7 +20,7 @@
</p> </p>
<div id="jsoneditor"></div> <div id="jsoneditor"></div>
<script type="text/javascript" > <script>
// create the editor // create the editor
var container = document.getElementById('jsoneditor'); var container = document.getElementById('jsoneditor');
var editor = new JSONEditor(container); var editor = new JSONEditor(container);

View File

@ -2,8 +2,10 @@
<html> <html>
<head> <head>
<title>JSONEditor | Viewer</title> <title>JSONEditor | Viewer</title>
<link rel="stylesheet" type="text/css" href="../jsoneditor.css"> <link rel="stylesheet" type="text/css" href="../jsoneditor.css">
<script type="text/javascript" src="../jsoneditor.js"></script> <script src="../jsoneditor.js"></script>
<style type="text/css"> <style type="text/css">
body { body {
font: 11pt arial; font: 11pt arial;
@ -19,7 +21,7 @@
</p> </p>
<div id="jsoneditor"></div> <div id="jsoneditor"></div>
<script type="text/javascript" > <script>
var container = document.getElementById('jsoneditor'); var container = document.getElementById('jsoneditor');
var options = { var options = {

View File

@ -4,15 +4,8 @@
<title>JSONEditor | Switch mode</title> <title>JSONEditor | Switch mode</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<!-- json editor -->
<link rel="stylesheet" type="text/css" href="../jsoneditor.css"> <link rel="stylesheet" type="text/css" href="../jsoneditor.css">
<script type="text/javascript" src="../jsoneditor.js"></script> <script src="../jsoneditor.js"></script>
<!-- ace editor -->
<script type="text/javascript" src="../asset/ace/ace.js"></script>
<!-- json lint -->
<script type="text/javascript" src="../asset/jsonlint/jsonlint.js"></script>
<style type="text/css"> <style type="text/css">
body { body {
@ -42,7 +35,7 @@
<div id="jsoneditor"></div> <div id="jsoneditor"></div>
<script type="text/javascript" > <script>
var container = document.getElementById('jsoneditor'); var container = document.getElementById('jsoneditor');
var options = { var options = {

View File

@ -2,6 +2,7 @@
<html> <html>
<head> <head>
<title>JSONEditor | Load and save</title> <title>JSONEditor | Load and save</title>
<link rel="stylesheet" type="text/css" href="../jsoneditor.css"> <link rel="stylesheet" type="text/css" href="../jsoneditor.css">
<script src="../jsoneditor.js"></script> <script src="../jsoneditor.js"></script>
@ -35,7 +36,7 @@
<div id="jsoneditor"></div> <div id="jsoneditor"></div>
<script type="text/javascript" > <script>
// create the editor // create the editor
var editor = new JSONEditor(document.getElementById('jsoneditor')); var editor = new JSONEditor(document.getElementById('jsoneditor'));

View File

@ -2,8 +2,10 @@
<html> <html>
<head> <head>
<title>JSONEditor | Basic usage</title> <title>JSONEditor | Basic usage</title>
<link rel="stylesheet" type="text/css" href="../jsoneditor.css"> <link rel="stylesheet" type="text/css" href="../jsoneditor.css">
<script type="text/javascript" src="../jsoneditor.js"></script> <script src="../jsoneditor.js"></script>
<style type="text/css"> <style type="text/css">
#jsoneditor { #jsoneditor {
width: 500px; width: 500px;
@ -22,7 +24,7 @@
<div id="jsoneditor"></div> <div id="jsoneditor"></div>
<script type="text/javascript" > <script>
var container = document.getElementById('jsoneditor'); var container = document.getElementById('jsoneditor');
var options = { var options = {

View File

@ -1,29 +1,24 @@
var fs = require('fs'), var fs = require('fs');
gulp = require('gulp'), var gulp = require('gulp');
gutil = require('gulp-util'), var gutil = require('gulp-util');
concat = require('gulp-concat'), var concatCss = require('gulp-concat-css');
concatCss = require('gulp-concat-css'), var minifyCSS = require('gulp-minify-css');
minifyCSS = require('gulp-minify-css'), var shell = require('gulp-shell');
rimraf = require('gulp-rimraf'), var mkdirp = require('mkdirp');
shell = require('gulp-shell'), var webpack = require('webpack');
merge = require('merge-stream'), var uglify = require('uglify-js');
mkdirp = require('mkdirp'),
webpack = require('webpack'),
uglify = require('uglify-js');
var ENTRY = './src/js/JSONEditor.js', var ENTRY = './src/js/JSONEditor.js';
HEADER = './src/js/header.js', var HEADER = './src/js/header.js';
FILE = 'jsoneditor.js', var FILE = 'jsoneditor.js';
FILE_MIN = 'jsoneditor.min.js', var FILE_MIN = 'jsoneditor.min.js';
FILE_MAP = 'jsoneditor.map', var FILE_MAP = 'jsoneditor.map';
DIST = './', var DIST = './';
JSONEDITOR_JS = DIST + FILE, var JSONEDITOR_JS = DIST + FILE;
JSONEDITOR_MIN_JS = DIST + FILE_MIN, var JSONEDITOR_MIN_JS = DIST + FILE_MIN;
JSONEDITOR_MAP_JS = DIST + FILE_MAP, var JSONEDITOR_MAP_JS = DIST + FILE_MAP;
JSONEDITOR_CSS = DIST + 'jsoneditor.css', var JSONEDITOR_CSS = DIST + 'jsoneditor.css';
JSONEDITOR_MIN_CSS = DIST + 'jsoneditor.min.css', var JSONEDITOR_MIN_CSS = DIST + 'jsoneditor.min.css';
DIST_ACE = './asset/ace/',
DIST_JSONLINT = './asset/jsonlint/';
// generate banner with today's date and correct version // generate banner with today's date and correct version
function createBanner() { function createBanner() {
@ -62,13 +57,11 @@ var uglifyConfig = {
// create a single instance of the compiler to allow caching // create a single instance of the compiler to allow caching
var compiler = webpack(webpackConfig); var compiler = webpack(webpackConfig);
// bundle javascript
gulp.task('bundle', function (done) { gulp.task('bundle', function (done) {
// update the banner contents (has a date in it which should stay up to date) // update the banner contents (has a date in it which should stay up to date)
bannerPlugin.banner = createBanner(); bannerPlugin.banner = createBanner();
// TODO: split this task in three tasks? bundle-js, bundle-css, bundle-img
// bundle javascript
compiler.run(function (err, stats) { compiler.run(function (err, stats) {
if (err) { if (err) {
gutil.log(err); gutil.log(err);
@ -78,8 +71,10 @@ gulp.task('bundle', function (done) {
done(); done();
}); });
});
// bundle css // bundle css
gulp.task('bundle-css', function () {
gulp.src([ gulp.src([
'src/css/jsoneditor.css', 'src/css/jsoneditor.css',
'src/css/contextmenu.css', 'src/css/contextmenu.css',
@ -94,8 +89,10 @@ gulp.task('bundle', function (done) {
gutil.log('bundled ' + JSONEDITOR_CSS); gutil.log('bundled ' + JSONEDITOR_CSS);
gutil.log('bundled ' + JSONEDITOR_MIN_CSS); gutil.log('bundled ' + JSONEDITOR_MIN_CSS);
});
// create a folder img and copy the icons // create a folder img and copy the icons
gulp.task('copy-img', function () {
mkdirp.sync('./img'); mkdirp.sync('./img');
gulp.src('./src/css/img/jsoneditor-icons.png') gulp.src('./src/css/img/jsoneditor-icons.png')
.pipe(gulp.dest('./img/')); .pipe(gulp.dest('./img/'));
@ -113,60 +110,12 @@ gulp.task('minify', ['bundle'], function () {
}); });
gulp.task('asset-clean', function () {
return gulp.src('./asset', {read: false})
.pipe(rimraf());
});
gulp.task('build-ace', shell.task([
// see https://github.com/ajaxorg/ace/#building-ace
'cd ./node_modules/ace/; '+
'npm install; ' +
'node ./Makefile.dryice.js -m; ' +
'cd ../..'
]));
gulp.task('asset-ace', ['build-ace', 'asset-clean'], function () {
// concatenate and copy ace files
var aceSrc = './node_modules/ace/build/src-min/';
mkdirp.sync(DIST_ACE);
// TODO: throw an error when aceSrc is missing?
var plugins = [
aceSrc + 'ext-searchbox.js',
aceSrc + 'mode-json.js',
aceSrc + 'theme-textmate.js',
'./src/js/ace/theme-jsoneditor.js'
];
return merge(
gulp.src([aceSrc + 'ace.js'].concat(plugins))
.pipe(concat('ace.js'))
.pipe(gulp.dest(DIST_ACE)),
gulp.src([aceSrc + 'worker-json.js'].concat(plugins))
.pipe(gulp.dest(DIST_ACE))
);
});
gulp.task('asset-jsonlint', ['asset-clean'], function (done) {
// copy and minify json lint file
mkdirp.sync(DIST_JSONLINT);
var result = uglify.minify(['./node_modules/jsonlint/lib/jsonlint.js']);
fs.writeFileSync(DIST_JSONLINT + 'jsonlint.js', result.code);
gutil.log('Minified ' + DIST_JSONLINT + 'jsonlint.js');
done();
});
gulp.task('build-assets', ['asset-clean', 'asset-ace', 'asset-jsonlint'], function () {});
// TODO: zip file using archiver // TODO: zip file using archiver
var pkg = 'jsoneditor-' + require('./package.json').version + '.zip'; var pkg = 'jsoneditor-' + require('./package.json').version + '.zip';
gulp.task('zip', shell.task([ gulp.task('zip', shell.task([
'zip ' + pkg + ' ' + 'zip ' + pkg + ' ' +
'README.md NOTICE LICENSE HISTORY.md jsoneditor.js jsoneditor.css jsoneditor.min.js jsoneditor.min.css jsoneditor.map img asset docs examples -r ' 'README.md NOTICE LICENSE HISTORY.md jsoneditor.js jsoneditor.css jsoneditor.min.js jsoneditor.min.css jsoneditor.map img docs examples -r '
])); ]));
// The default task (called when you run `gulp`) // The default task (called when you run `gulp`)
gulp.task('default', ['bundle', 'minify']); gulp.task('default', ['bundle', 'bundle-css', 'copy-img', 'minify']);

1
index.js Normal file
View File

@ -0,0 +1 @@
module.exports = require('./src/js/JSONEditor');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

17
jsoneditor.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{ {
"name": "jsoneditor", "name": "jsoneditor",
"version": "3.2.0", "version": "3.2.0",
"main": "jsoneditor.js", "main": "./index",
"description": "A web-based tool to view, edit and format JSON", "description": "A web-based tool to view, edit and format JSON",
"tags": [ "tags": [
"json", "json",
@ -20,18 +20,16 @@
"build": "gulp", "build": "gulp",
"build-assets": "gulp build-assets" "build-assets": "gulp build-assets"
}, },
"dependencies": {}, "dependencies": {
"brace": "^0.4.1",
"jsonlint": "^1.6.2"
},
"devDependencies": { "devDependencies": {
"ace": "git://github.com/aja0.0",
"gulp": "^3.8.11", "gulp": "^3.8.11",
"gulp-concat": "^2.4.3",
"gulp-concat-css": "^2.0.0", "gulp-concat-css": "^2.0.0",
"gulp-minify-css": "^0.4.5", "gulp-minify-css": "^0.4.5",
"gulp-rimraf": "^0.1.1",
"gulp-shell": "^0.3.0", "gulp-shell": "^0.3.0",
"gulp-util": "^3.0.3", "gulp-util": "^3.0.3",
"jsonlint": "^1.6.2",
"merge-stream": "^0.1.7",
"mkdirp": "^0.5.0", "mkdirp": "^0.5.0",
"uglify-js": "^2.4.16", "uglify-js": "^2.4.16",
"webpack": "^1.5.3" "webpack": "^1.5.3"

View File

@ -28,7 +28,7 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
define('ace/theme/jsoneditor', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) { ace.define('ace/theme/jsoneditor', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
exports.isDark = false; exports.isDark = false;
exports.cssClass = "ace-jsoneditor"; exports.cssClass = "ace-jsoneditor";

View File

@ -1,3 +1,8 @@
var ace = require('brace');
require('brace/mode/json');
require('brace/ext/searchbox');
require('./ace/theme-jsoneditor');
var modeswitcher = require('./modeswitcher'); var modeswitcher = require('./modeswitcher');
var util = require('./util'); var util = require('./util');

View File

@ -1,3 +1,5 @@
var jsonlint = require('jsonlint');
/** /**
* Parse JSON using the parser built-in in the browser. * Parse JSON using the parser built-in in the browser.
* On exception, the jsonString is validated and a detailed error is thrown. * On exception, the jsonString is validated and a detailed error is thrown.

View File

@ -1,4 +1,4 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!DOCTYPE HTML>
<html> <html>
<head> <head>
<title>CouchDB Document Editor</title> <title>CouchDB Document Editor</title>
@ -9,8 +9,8 @@
<link rel="shortcut icon" href="../app/web/favicon.ico"> <link rel="shortcut icon" href="../app/web/favicon.ico">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript" src="../jsoneditor/js/jsoneditor.js"></script> <script src="../jsoneditor/js/jsoneditor.js"></script>
<link rel="stylesheet" type="text/css" href="../jsoneditor/css/jsoneditor.css"> <link rel="stylesheet" type="text/css" href="../jsoneditor/css/jsoneditor.css">
<style type="text/css"> <style type="text/css">
@ -32,7 +32,7 @@
} }
</style> </style>
<script type="text/javascript"> <script>
var editor = null; var editor = null;
function init() { function init() {

View File

@ -1,36 +0,0 @@
/*
RequireJS 2.1.13 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
*/
var requirejs,require,define;
(function(ba){function G(b){return"[object Function]"===K.call(b)}function H(b){return"[object Array]"===K.call(b)}function v(b,c){if(b){var d;for(d=0;d<b.length&&(!b[d]||!c(b[d],d,b));d+=1);}}function T(b,c){if(b){var d;for(d=b.length-1;-1<d&&(!b[d]||!c(b[d],d,b));d-=1);}}function t(b,c){return fa.call(b,c)}function m(b,c){return t(b,c)&&b[c]}function B(b,c){for(var d in b)if(t(b,d)&&c(b[d],d))break}function U(b,c,d,e){c&&B(c,function(c,g){if(d||!t(b,g))e&&"object"===typeof c&&c&&!H(c)&&!G(c)&&!(c instanceof
RegExp)?(b[g]||(b[g]={}),U(b[g],c,d,e)):b[g]=c});return b}function u(b,c){return function(){return c.apply(b,arguments)}}function ca(b){throw b;}function da(b){if(!b)return b;var c=ba;v(b.split("."),function(b){c=c[b]});return c}function C(b,c,d,e){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=e;d&&(c.originalError=d);return c}function ga(b){function c(a,k,b){var f,l,c,d,e,g,i,p,k=k&&k.split("/"),h=j.map,n=h&&h["*"];if(a){a=a.split("/");l=a.length-1;j.nodeIdCompat&&
Q.test(a[l])&&(a[l]=a[l].replace(Q,""));"."===a[0].charAt(0)&&k&&(l=k.slice(0,k.length-1),a=l.concat(a));l=a;for(c=0;c<l.length;c++)if(d=l[c],"."===d)l.splice(c,1),c-=1;else if(".."===d&&!(0===c||1==c&&".."===l[2]||".."===l[c-1])&&0<c)l.splice(c-1,2),c-=2;a=a.join("/")}if(b&&h&&(k||n)){l=a.split("/");c=l.length;a:for(;0<c;c-=1){e=l.slice(0,c).join("/");if(k)for(d=k.length;0<d;d-=1)if(b=m(h,k.slice(0,d).join("/")))if(b=m(b,e)){f=b;g=c;break a}!i&&(n&&m(n,e))&&(i=m(n,e),p=c)}!f&&i&&(f=i,g=p);f&&(l.splice(0,
g,f),a=l.join("/"))}return(f=m(j.pkgs,a))?f:a}function d(a){z&&v(document.getElementsByTagName("script"),function(k){if(k.getAttribute("data-requiremodule")===a&&k.getAttribute("data-requirecontext")===i.contextName)return k.parentNode.removeChild(k),!0})}function e(a){var k=m(j.paths,a);if(k&&H(k)&&1<k.length)return k.shift(),i.require.undef(a),i.makeRequire(null,{skipMap:!0})([a]),!0}function n(a){var k,c=a?a.indexOf("!"):-1;-1<c&&(k=a.substring(0,c),a=a.substring(c+1,a.length));return[k,a]}function p(a,
k,b,f){var l,d,e=null,g=k?k.name:null,j=a,p=!0,h="";a||(p=!1,a="_@r"+(K+=1));a=n(a);e=a[0];a=a[1];e&&(e=c(e,g,f),d=m(r,e));a&&(e?h=d&&d.normalize?d.normalize(a,function(a){return c(a,g,f)}):c(a,g,f):(h=c(a,g,f),a=n(h),e=a[0],h=a[1],b=!0,l=i.nameToUrl(h)));b=e&&!d&&!b?"_unnormalized"+(O+=1):"";return{prefix:e,name:h,parentMap:k,unnormalized:!!b,url:l,originalName:j,isDefine:p,id:(e?e+"!"+h:h)+b}}function s(a){var k=a.id,b=m(h,k);b||(b=h[k]=new i.Module(a));return b}function q(a,k,b){var f=a.id,c=m(h,
f);if(t(r,f)&&(!c||c.defineEmitComplete))"defined"===k&&b(r[f]);else if(c=s(a),c.error&&"error"===k)b(c.error);else c.on(k,b)}function w(a,b){var c=a.requireModules,f=!1;if(b)b(a);else if(v(c,function(b){if(b=m(h,b))b.error=a,b.events.error&&(f=!0,b.emit("error",a))}),!f)g.onError(a)}function x(){R.length&&(ha.apply(A,[A.length,0].concat(R)),R=[])}function y(a){delete h[a];delete V[a]}function F(a,b,c){var f=a.map.id;a.error?a.emit("error",a.error):(b[f]=!0,v(a.depMaps,function(f,d){var e=f.id,g=
m(h,e);g&&(!a.depMatched[d]&&!c[e])&&(m(b,e)?(a.defineDep(d,r[e]),a.check()):F(g,b,c))}),c[f]=!0)}function D(){var a,b,c=(a=1E3*j.waitSeconds)&&i.startTime+a<(new Date).getTime(),f=[],l=[],g=!1,h=!0;if(!W){W=!0;B(V,function(a){var i=a.map,j=i.id;if(a.enabled&&(i.isDefine||l.push(a),!a.error))if(!a.inited&&c)e(j)?g=b=!0:(f.push(j),d(j));else if(!a.inited&&(a.fetched&&i.isDefine)&&(g=!0,!i.prefix))return h=!1});if(c&&f.length)return a=C("timeout","Load timeout for modules: "+f,null,f),a.contextName=
i.contextName,w(a);h&&v(l,function(a){F(a,{},{})});if((!c||b)&&g)if((z||ea)&&!X)X=setTimeout(function(){X=0;D()},50);W=!1}}function E(a){t(r,a[0])||s(p(a[0],null,!0)).init(a[1],a[2])}function I(a){var a=a.currentTarget||a.srcElement,b=i.onScriptLoad;a.detachEvent&&!Y?a.detachEvent("onreadystatechange",b):a.removeEventListener("load",b,!1);b=i.onScriptError;(!a.detachEvent||Y)&&a.removeEventListener("error",b,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}function J(){var a;for(x();A.length;){a=
A.shift();if(null===a[0])return w(C("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));E(a)}}var W,Z,i,L,X,j={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},h={},V={},$={},A=[],r={},S={},aa={},K=1,O=1;L={require:function(a){return a.require?a.require:a.require=i.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?r[a.map.id]=a.exports:a.exports=r[a.map.id]={}},module:function(a){return a.module?a.module:a.module=
{id:a.map.id,uri:a.map.url,config:function(){return m(j.config,a.map.id)||{}},exports:a.exports||(a.exports={})}}};Z=function(a){this.events=m($,a.id)||{};this.map=a;this.shim=m(j.shim,a.id);this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};Z.prototype={init:function(a,b,c,f){f=f||{};if(!this.inited){this.factory=b;if(c)this.on("error",c);else this.events.error&&(c=u(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=c;this.inited=
!0;this.ignore=f.ignore;f.enabled||this.enabled?this.enable():this.check()}},defineDep:function(a,b){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=b)},fetch:function(){if(!this.fetched){this.fetched=!0;i.startTime=(new Date).getTime();var a=this.map;if(this.shim)i.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],u(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=
this.map.url;S[a]||(S[a]=!0,i.load(this.map.id,a))},check:function(){if(this.enabled&&!this.enabling){var a,b,c=this.map.id;b=this.depExports;var f=this.exports,l=this.factory;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(1>this.depCount&&!this.defined){if(G(l)){if(this.events.error&&this.map.isDefine||g.onError!==ca)try{f=i.execCb(c,l,b,f)}catch(d){a=d}else f=i.execCb(c,l,b,f);this.map.isDefine&&void 0===f&&((b=this.module)?f=b.exports:this.usingExports&&
(f=this.exports));if(a)return a.requireMap=this.map,a.requireModules=this.map.isDefine?[this.map.id]:null,a.requireType=this.map.isDefine?"define":"require",w(this.error=a)}else f=l;this.exports=f;if(this.map.isDefine&&!this.ignore&&(r[c]=f,g.onResourceLoad))g.onResourceLoad(i,this.map,this.depMaps);y(c);this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else this.fetch()}},callPlugin:function(){var a=
this.map,b=a.id,d=p(a.prefix);this.depMaps.push(d);q(d,"defined",u(this,function(f){var l,d;d=m(aa,this.map.id);var e=this.map.name,P=this.map.parentMap?this.map.parentMap.name:null,n=i.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(f.normalize&&(e=f.normalize(e,function(a){return c(a,P,!0)})||""),f=p(a.prefix+"!"+e,this.map.parentMap),q(f,"defined",u(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),d=m(h,f.id)){this.depMaps.push(f);
if(this.events.error)d.on("error",u(this,function(a){this.emit("error",a)}));d.enable()}}else d?(this.map.url=i.nameToUrl(d),this.load()):(l=u(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),l.error=u(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];B(h,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&y(a.map.id)});w(a)}),l.fromText=u(this,function(f,c){var d=a.name,e=p(d),P=M;c&&(f=c);P&&(M=!1);s(e);t(j.config,b)&&(j.config[d]=j.config[b]);try{g.exec(f)}catch(h){return w(C("fromtexteval",
"fromText eval for "+b+" failed: "+h,h,[b]))}P&&(M=!0);this.depMaps.push(e);i.completeLoad(d);n([d],l)}),f.load(a.name,n,l,j))}));i.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){V[this.map.id]=this;this.enabling=this.enabled=!0;v(this.depMaps,u(this,function(a,b){var c,f;if("string"===typeof a){a=p(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=m(L,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;q(a,"defined",u(this,function(a){this.defineDep(b,
a);this.check()}));this.errback&&q(a,"error",u(this,this.errback))}c=a.id;f=h[c];!t(L,c)&&(f&&!f.enabled)&&i.enable(a,this)}));B(this.pluginMaps,u(this,function(a){var b=m(h,a.id);b&&!b.enabled&&i.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){v(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};i={config:j,contextName:b,registry:h,defined:r,urlFetched:S,defQueue:A,Module:Z,makeModuleMap:p,
nextTick:g.nextTick,onError:w,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=j.shim,c={paths:!0,bundles:!0,config:!0,map:!0};B(a,function(a,b){c[b]?(j[b]||(j[b]={}),U(j[b],a,!0,!0)):j[b]=a});a.bundles&&B(a.bundles,function(a,b){v(a,function(a){a!==b&&(aa[a]=b)})});a.shim&&(B(a.shim,function(a,c){H(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=i.makeShimExports(a);b[c]=a}),j.shim=b);a.packages&&v(a.packages,function(a){var b,
a="string"===typeof a?{name:a}:a;b=a.name;a.location&&(j.paths[b]=a.location);j.pkgs[b]=a.name+"/"+(a.main||"main").replace(ia,"").replace(Q,"")});B(h,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=p(b))});if(a.deps||a.callback)i.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(ba,arguments));return b||a.exports&&da(a.exports)}},makeRequire:function(a,e){function j(c,d,m){var n,q;e.enableBuildCallback&&(d&&G(d))&&(d.__requireJsBuild=
!0);if("string"===typeof c){if(G(d))return w(C("requireargs","Invalid require call"),m);if(a&&t(L,c))return L[c](h[a.id]);if(g.get)return g.get(i,c,a,j);n=p(c,a,!1,!0);n=n.id;return!t(r,n)?w(C("notloaded",'Module name "'+n+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):r[n]}J();i.nextTick(function(){J();q=s(p(null,a));q.skipMap=e.skipMap;q.init(c,d,m,{enabled:!0});D()});return j}e=e||{};U(j,{isBrowser:z,toUrl:function(b){var d,e=b.lastIndexOf("."),k=b.split("/")[0];if(-1!==
e&&(!("."===k||".."===k)||1<e))d=b.substring(e,b.length),b=b.substring(0,e);return i.nameToUrl(c(b,a&&a.id,!0),d,!0)},defined:function(b){return t(r,p(b,a,!1,!0).id)},specified:function(b){b=p(b,a,!1,!0).id;return t(r,b)||t(h,b)}});a||(j.undef=function(b){x();var c=p(b,a,!0),e=m(h,b);d(b);delete r[b];delete S[c.url];delete $[b];T(A,function(a,c){a[0]===b&&A.splice(c,1)});e&&(e.events.defined&&($[b]=e.events),y(b))});return j},enable:function(a){m(h,a.id)&&s(a).enable()},completeLoad:function(a){var b,
c,d=m(j.shim,a)||{},g=d.exports;for(x();A.length;){c=A.shift();if(null===c[0]){c[0]=a;if(b)break;b=!0}else c[0]===a&&(b=!0);E(c)}c=m(h,a);if(!b&&!t(r,a)&&c&&!c.inited){if(j.enforceDefine&&(!g||!da(g)))return e(a)?void 0:w(C("nodefine","No define call for "+a,null,[a]));E([a,d.deps||[],d.exportsFn])}D()},nameToUrl:function(a,b,c){var d,e,h;(d=m(j.pkgs,a))&&(a=d);if(d=m(aa,a))return i.nameToUrl(d,b,c);if(g.jsExtRegExp.test(a))d=a+(b||"");else{d=j.paths;a=a.split("/");for(e=a.length;0<e;e-=1)if(h=a.slice(0,
e).join("/"),h=m(d,h)){H(h)&&(h=h[0]);a.splice(0,e,h);break}d=a.join("/");d+=b||(/^data\:|\?/.test(d)||c?"":".js");d=("/"===d.charAt(0)||d.match(/^[\w\+\.\-]+:/)?"":j.baseUrl)+d}return j.urlArgs?d+((-1===d.indexOf("?")?"?":"&")+j.urlArgs):d},load:function(a,b){g.load(i,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if("load"===a.type||ja.test((a.currentTarget||a.srcElement).readyState))N=null,a=I(a),i.completeLoad(a.id)},onScriptError:function(a){var b=I(a);if(!e(b.id))return w(C("scripterror",
"Script error for: "+b.id,a,[b.id]))}};i.require=i.makeRequire();return i}var g,x,y,D,I,E,N,J,s,O,ka=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,la=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,Q=/\.js$/,ia=/^\.\//;x=Object.prototype;var K=x.toString,fa=x.hasOwnProperty,ha=Array.prototype.splice,z=!!("undefined"!==typeof window&&"undefined"!==typeof navigator&&window.document),ea=!z&&"undefined"!==typeof importScripts,ja=z&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,
Y="undefined"!==typeof opera&&"[object Opera]"===opera.toString(),F={},q={},R=[],M=!1;if("undefined"===typeof define){if("undefined"!==typeof requirejs){if(G(requirejs))return;q=requirejs;requirejs=void 0}"undefined"!==typeof require&&!G(require)&&(q=require,require=void 0);g=requirejs=function(b,c,d,e){var n,p="_";!H(b)&&"string"!==typeof b&&(n=b,H(c)?(b=c,c=d,d=e):b=[]);n&&n.context&&(p=n.context);(e=m(F,p))||(e=F[p]=g.s.newContext(p));n&&e.configure(n);return e.require(b,c,d)};g.config=function(b){return g(b)};
g.nextTick="undefined"!==typeof setTimeout?function(b){setTimeout(b,4)}:function(b){b()};require||(require=g);g.version="2.1.13";g.jsExtRegExp=/^\/|:|\?|\.js$/;g.isBrowser=z;x=g.s={contexts:F,newContext:ga};g({});v(["toUrl","undef","defined","specified"],function(b){g[b]=function(){var c=F._;return c.require[b].apply(c,arguments)}});if(z&&(y=x.head=document.getElementsByTagName("head")[0],D=document.getElementsByTagName("base")[0]))y=x.head=D.parentNode;g.onError=ca;g.createNode=function(b){var c=
b.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");c.type=b.scriptType||"text/javascript";c.charset="utf-8";c.async=!0;return c};g.load=function(b,c,d){var e=b&&b.config||{};if(z)return e=g.createNode(e,c,d),e.setAttribute("data-requirecontext",b.contextName),e.setAttribute("data-requiremodule",c),e.attachEvent&&!(e.attachEvent.toString&&0>e.attachEvent.toString().indexOf("[native code"))&&!Y?(M=!0,e.attachEvent("onreadystatechange",b.onScriptLoad)):
(e.addEventListener("load",b.onScriptLoad,!1),e.addEventListener("error",b.onScriptError,!1)),e.src=d,J=e,D?y.insertBefore(e,D):y.appendChild(e),J=null,e;if(ea)try{importScripts(d),b.completeLoad(c)}catch(m){b.onError(C("importscripts","importScripts failed for "+c+" at "+d,m,[c]))}};z&&!q.skipDataMain&&T(document.getElementsByTagName("script"),function(b){y||(y=b.parentNode);if(I=b.getAttribute("data-main"))return s=I,q.baseUrl||(E=s.split("/"),s=E.pop(),O=E.length?E.join("/")+"/":"./",q.baseUrl=
O),s=s.replace(Q,""),g.jsExtRegExp.test(s)&&(s=I),q.deps=q.deps?q.deps.concat(s):[s],!0});define=function(b,c,d){var e,g;"string"!==typeof b&&(d=c,c=b,b=null);H(c)||(d=c,c=null);!c&&G(d)&&(c=[],d.length&&(d.toString().replace(ka,"").replace(la,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c)));if(M){if(!(e=J))N&&"interactive"===N.readyState||T(document.getElementsByTagName("script"),function(b){if("interactive"===b.readyState)return N=b}),e=N;e&&(b||
(b=e.getAttribute("data-requiremodule")),g=F[e.getAttribute("data-requirecontext")])}(g?g.defQueue:R).push([b,c,d])};define.amd={jQuery:!0};g.exec=function(b){return eval(b)};g(q)}})(this);

View File

@ -1,107 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<!-- require.js -->
<script src="require.js"></script>
<script>
require.config({
packages: [
{
name: 'JSONEditor',
location: '../src/js/',
main: 'JSONEditor'
}
],
paths: {
'theme-jsoneditor.js': '../src/js/ace/theme-jsoneditor.js'
}
});
</script>
<!-- json editor -->
<link rel="stylesheet" type="text/css" href="../jsoneditor.css">
<!-- ace editor -->
<script type="text/javascript" src="../asset/ace/ace.js"></script>
<!-- json lint -->
<script type="text/javascript" src="../asset/jsonlint/jsonlint.js"></script>
<style type="text/css">
body {
font: 10.5pt arial;
color: #4d4d4d;
line-height: 150%;
width: 500px;
}
code {
background-color: #f5f5f5;
}
#jsoneditor {
width: 500px;
height: 500px;
}
</style>
</head>
<body>
<p>
Switch editor mode using the mode box.
Note that the mode can be changed programmatically as well using the method
<code>editor.setMode(mode)</code>, try it in the console of your browser.
</p>
<div id="jsoneditor"></div>
<script type="text/javascript" >
var container, options, json, editor;
require(['JSONEditor'], function (JSONEditor) {
container = document.getElementById('jsoneditor');
options = {
mode: 'tree',
modes: ['code', 'form', 'text', 'tree', 'view'], // allowed modes
error: function (err) {
console.trace();
alert(err.toString());
},
editable: function (node) {
console.log(node);
switch(node.field) {
case '_id':
return false;
case '_field':
return {
field: false,
value: true
};
default:
return true;
}
}
};
json = {
"_id": "1234",
"_field": "ABCD",
"array": [1, 2, 3],
"boolean": true,
"null": null,
"number": 123,
"object": {"a": "b", "c": {"d": "e", "f": "g"}},
"string": "Hello World",
"url": "http://jsoneditoronline.org"
};
editor = new JSONEditor(container, options, json);
});
</script>
</body>
</html>

View File

@ -1,19 +1,12 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <!--<meta http-equiv="Content-Type" content="text/html;charset=utf-8">-->
<!-- json editor --> <script src="../jsoneditor.js"></script>
<script type="text/javascript" src="../jsoneditor.js"></script>
<link rel="stylesheet" type="text/css" href="../jsoneditor.css"> <link rel="stylesheet" type="text/css" href="../jsoneditor.css">
<!-- ace editor --> <style>
<script type="text/javascript" src="../asset/ace/ace.js"></script>
<!-- json lint -->
<script type="text/javascript" src="../asset/jsonlint/jsonlint.js"></script>
<style type="text/css">
body { body {
font: 10.5pt arial; font: 10.5pt arial;
color: #4d4d4d; color: #4d4d4d;
@ -41,7 +34,7 @@
<div id="jsoneditor"></div> <div id="jsoneditor"></div>
<script type="text/javascript" > <script>
var container, options, json, editor; var container, options, json, editor;
container = document.getElementById('jsoneditor'); container = document.getElementById('jsoneditor');

View File

@ -3,16 +3,9 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<!-- json editor --> <script src="../jsoneditor.min.js"></script>
<script type="text/javascript" src="../jsoneditor.min.js"></script>
<link rel="stylesheet" type="text/css" href="../jsoneditor.min.css"> <link rel="stylesheet" type="text/css" href="../jsoneditor.min.css">
<!-- ace editor -->
<script type="text/javascript" src="../asset/ace/ace.js"></script>
<!-- json lint -->
<script type="text/javascript" src="../asset/jsonlint/jsonlint.js"></script>
<style type="text/css"> <style type="text/css">
body { body {
font: 10.5pt arial; font: 10.5pt arial;
@ -41,7 +34,7 @@
<div id="jsoneditor"></div> <div id="jsoneditor"></div>
<script type="text/javascript" > <script>
var container, options, json, editor; var container, options, json, editor;
container = document.getElementById('jsoneditor'); container = document.getElementById('jsoneditor');