json-schema-editor
Advanced tools
Comparing version
@@ -424,2 +424,6 @@ /******/ (function(modules) { // webpackBootstrap | ||
var i = event.target.parentElement.dataset.index; | ||
var requiredIndex = this.state.required.indexOf(this.state.propertyNames[i]); | ||
if (requiredIndex !== -1) { | ||
this.state.required.splice(requiredIndex, 1); | ||
} | ||
this.state.properties.splice(i, 1); | ||
@@ -614,5 +618,5 @@ this.state.propertyNames.splice(i, 1); | ||
module.exports = window.JSONSchemaEditor; | ||
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') module.exports = window.JSONSchemaEditor; | ||
/***/ } | ||
/******/ ]); |
{ | ||
"name": "json-schema-editor", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "React based editor for JSON Schemas", | ||
"main": "src/index.js", | ||
"main": "src/index.jsx", | ||
"dependencies": {}, | ||
@@ -7,0 +7,0 @@ "devDependencies": { |
//json-editor-plugin.js | ||
JSONEditor.defaults.resolvers.unshift(function(schema) { | ||
if (schema.type === "object" && schema.format === "schema") { | ||
return "schema"; | ||
} | ||
if (JSONEditor) { | ||
JSONEditor.defaults.resolvers.unshift(function(schema) { | ||
if (schema.type === "object" && schema.format === "schema") { | ||
return "schema"; | ||
} | ||
// If no valid editor is returned, the next resolver function will be used | ||
}); | ||
// If no valid editor is returned, the next resolver function will be used | ||
}); | ||
JSONEditor.defaults.editors.schema = JSONEditor.AbstractEditor.extend({ | ||
setValue: function(value,initial) { | ||
this.value = value; | ||
this.schemaeditor.setValue(value) | ||
this.onChange(); | ||
}, | ||
getValue: function() { | ||
if (typeof this.schemaeditor != 'undefined') | ||
return this.schemaeditor.getValue(); | ||
else | ||
return {} | ||
}, | ||
register: function() { | ||
this._super(); | ||
if(!this.input) return; | ||
this.input.setAttribute('name', this.formname); | ||
}, | ||
unregister: function() { | ||
this._super(); | ||
if(!this.input) return; | ||
this.input.removeAttribute('name'); | ||
}, | ||
getNumColumns: function() { | ||
return 12; | ||
}, | ||
build: function() { | ||
var self = this; | ||
if(!this.options.compact) { | ||
this.label = this.header = this.theme.getFormInputLabel(this.getTitle()); | ||
} | ||
if(this.schema.description) this.description = this.theme.getFormInputDescription(this.schema.description); | ||
if(this.options.compact) this.container.className += ' compact'; | ||
JSONEditor.defaults.editors.schema = JSONEditor.AbstractEditor.extend({ | ||
setValue: function(value,initial) { | ||
this.value = value; | ||
this.schemaeditor.setValue(value) | ||
this.onChange(); | ||
}, | ||
getValue: function() { | ||
if (typeof this.schemaeditor != 'undefined') | ||
return this.schemaeditor.getValue(); | ||
else | ||
return {} | ||
}, | ||
register: function() { | ||
this._super(); | ||
if(!this.input) return; | ||
this.input.setAttribute('name', this.formname); | ||
}, | ||
unregister: function() { | ||
this._super(); | ||
if(!this.input) return; | ||
this.input.removeAttribute('name'); | ||
}, | ||
getNumColumns: function() { | ||
return 12; | ||
}, | ||
build: function() { | ||
var self = this; | ||
if(!this.options.compact) { | ||
this.label = this.header = this.theme.getFormInputLabel(this.getTitle()); | ||
} | ||
if(this.schema.description) this.description = this.theme.getFormInputDescription(this.schema.description); | ||
if(this.options.compact) this.container.className += ' compact'; | ||
this.input = document.createElement('div') | ||
this.control = this.theme.getFormControl(this.label, this.input, this.description); | ||
this.input = document.createElement('div') | ||
this.control = this.theme.getFormControl(this.label, this.input, this.description); | ||
if(this.schema.readOnly || this.schema.readonly) { | ||
this.always_disabled = true; | ||
this.input.disabled = true; | ||
} | ||
if(this.schema.readOnly || this.schema.readonly) { | ||
this.always_disabled = true; | ||
this.input.disabled = true; | ||
} | ||
this.container.appendChild(this.control); | ||
this.container.appendChild(this.control); | ||
this.schemaeditor = new JSONSchemaEditor(this.input, { | ||
startval: {} | ||
}); | ||
this.schemaeditor.on('change', function() { | ||
self.onChange(true); | ||
}); | ||
}, | ||
enable: function() { | ||
if(!this.always_disabled) { | ||
this.input.disabled = false; | ||
this.schemaeditor = new JSONSchemaEditor(this.input, { | ||
startval: {} | ||
}); | ||
this.schemaeditor.on('change', function() { | ||
self.onChange(true); | ||
}); | ||
}, | ||
enable: function() { | ||
if(!this.always_disabled) { | ||
this.input.disabled = false; | ||
} | ||
this._super(); | ||
}, | ||
disable: function() { | ||
this.input.disabled = true; | ||
this._super(); | ||
}, | ||
destroy: function() { | ||
if(this.label && this.label.parentNode) this.label.parentNode.removeChild(this.label); | ||
if(this.description && this.description.parentNode) this.description.parentNode.removeChild(this.description); | ||
if(this.input && this.input.parentNode) this.input.parentNode.removeChild(this.input); | ||
this._super(); | ||
} | ||
this._super(); | ||
}, | ||
disable: function() { | ||
this.input.disabled = true; | ||
this._super(); | ||
}, | ||
destroy: function() { | ||
if(this.label && this.label.parentNode) this.label.parentNode.removeChild(this.label); | ||
if(this.description && this.description.parentNode) this.description.parentNode.removeChild(this.description); | ||
if(this.input && this.input.parentNode) this.input.parentNode.removeChild(this.input); | ||
this._super(); | ||
} | ||
}); | ||
}); | ||
} |
module.exports = { | ||
entry: './src/index.js', | ||
entry: './src/index.jsx', | ||
output: { | ||
@@ -4,0 +4,0 @@ path: 'dist', |
36330
1.8%1068
1.04%