json-schema-editor
Advanced tools
Comparing version
@@ -45,3 +45,3 @@ /******/ (function(modules) { // webpackBootstrap | ||
/* 0 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports) { | ||
@@ -254,3 +254,3 @@ 'use strict'; | ||
change: function change(event) { | ||
this.state[event.target.name] = event.target.value; | ||
this.state[event.target.name] = parseInt(event.target.value); | ||
this.setState(this.state); | ||
@@ -422,3 +422,5 @@ }, | ||
componentWillReceiveProps: function componentWillReceiveProps(newProps) { | ||
this.setState(this.propsToState(newProps)); | ||
if (!this.state) { | ||
this.setState(this.propsToState(newProps)); | ||
} | ||
}, | ||
@@ -476,3 +478,3 @@ deleteItem: function deleteItem(event) { | ||
var name = self.state.propertyNames[index]; | ||
if (typeof self.refs['item' + index] != 'undefined' && name.length > 0) properties[name] = self.refs['item' + index].export(); | ||
if (typeof self.refs['item' + index] != 'undefined' && name && name.length > 0) properties[name] = self.refs['item' + index].export(); | ||
}); | ||
@@ -623,3 +625,3 @@ return { | ||
/***/ } | ||
/***/ }) | ||
/******/ ]); |
{ | ||
"name": "json-schema-editor", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "React based editor for JSON Schemas", | ||
@@ -17,5 +17,5 @@ "main": "dist/jsonschemaeditor.js", | ||
}, | ||
"repository" : { | ||
"type" : "git", | ||
"url" : "https://github.com/thomas4019/json-schema-editor.git" | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/thomas4019/json-schema-editor.git" | ||
}, | ||
@@ -22,0 +22,0 @@ "scripts": { |
# JSON Schema Editor | ||
 | ||
Generates HTML for creating and modifying [json schemas](http://json-schema.org). I created this because [json-editor](https://github.com/jdorn/json-editor) is not good at modifying schemas (using the [meta schema](http://json-schema.org/schema)) and couldn't find any other good UI for making json schemas. | ||
@@ -7,17 +9,24 @@ | ||
-------------------- | ||
1. Make sure React is loaded on your page. If you're not using React on your page yet you can use the following scripts to load it from a CDN. | ||
1. Make sure React is loaded on your page. Read more at [facebook/react](https://github.com/facebook/react#installation). | ||
```html | ||
<script src="https://fb.me/react-15.0.1.js"></script> | ||
<script src="https://fb.me/react-dom-15.0.1.js"></script> | ||
``` | ||
2. Include JSON Schema Editor | ||
2. Include the JSON Schema Editor javascript file. | ||
- Using npm: | ||
```sh | ||
npm install json-schema-editor | ||
``` | ||
```javascript | ||
var JSONSchemaEditor = require('json-schema-editor'); | ||
``` | ||
- Old-fashioned style: | ||
```html | ||
<script src="node_modules/dist/jsonschemaeditor.js"></script> | ||
``` | ||
```html | ||
<script src="node_modules/dist/jsonschemaeditor.js"></script> | ||
``` | ||
3. Add an element to your page to contain the editor | ||
3. Add an element to your page to contain the editor. | ||
```html | ||
@@ -45,2 +54,3 @@ <div id="container"></div> | ||
Here is what the [product schema](http://json-schema.org/example1.html) example looks like rendered. | ||
 | ||
@@ -54,2 +64,2 @@ | ||
* patternProperties | ||
* allOf, anyOf, oneOf | ||
* allOf, anyOf, oneOf |
@@ -140,3 +140,3 @@ window.JSONSchemaEditor = function(element,options) { | ||
change: function(event) { | ||
this.state[event.target.name] = event.target.value; | ||
this.state[event.target.name] = parseInt(event.target.value); | ||
this.setState(this.state); | ||
@@ -260,3 +260,5 @@ }, | ||
componentWillReceiveProps: function(newProps) { | ||
this.setState(this.propsToState(newProps)) | ||
if (!this.state) { | ||
this.setState(this.propsToState(newProps)) | ||
} | ||
}, | ||
@@ -316,3 +318,3 @@ deleteItem: function(event) { | ||
var name = self.state.propertyNames[index]; | ||
if (typeof self.refs['item'+index] != 'undefined' && name.length > 0) | ||
if (typeof self.refs['item'+index] != 'undefined' && name && name.length > 0) | ||
properties[name] = self.refs['item'+index].export(); | ||
@@ -319,0 +321,0 @@ }); |
36672
0.43%1072
0.37%63
21.15%7
-12.5%