Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-editor

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-editor - npm Package Compare versions

Comparing version 0.7.22 to 0.7.23

examples/selectize.html

2

Gruntfile.js

@@ -41,2 +41,3 @@ 'use strict';

'src/editors/select.js',
'src/editors/selectize.js',
'src/editors/multiselect.js',

@@ -46,2 +47,3 @@ 'src/editors/base64.js',

'src/editors/checkbox.js',
'src/editors/array/selectize.js',

@@ -48,0 +50,0 @@ // All the themes and iconlibs

2

package.json

@@ -5,3 +5,3 @@ {

"description": "JSON Schema based editor",
"version": "0.7.22",
"version": "0.7.23",
"main": "dist/jsoneditor.js",

@@ -8,0 +8,0 @@ "author": {

@@ -32,2 +32,3 @@ JSON Editor

* [Select2](http://ivaynberg.github.io/select2/) for nicer Select boxes
* [Selectize](http://brianreavis.github.io/selectize.js/) for nicer Select & Array boxes

@@ -1148,3 +1149,12 @@ Usage

Select2 & Selectize Support
----------------
Select2 support is enabled by default and will become active if the Select2 library is detected.
Selectize support is enabled via the following snippet:
```js
JSONEditor.plugins.selectize.enable = true;
```
See the demo for an example of the `array` and `select` editor with Selectize support enabled.
Custom Validation

@@ -1151,0 +1161,0 @@ ----------------

@@ -40,4 +40,10 @@ var JSONEditor = function(element,options) {

self._getDefinitions(self.schema);
self.validator = new JSONEditor.Validator(self);
// Validator options
var validator_options = {};
if(self.options.custom_validators) {
validator_options.custom_validators = self.options.custom_validators;
}
self.validator = new JSONEditor.Validator(self,null,validator_options);
// Create the root editor

@@ -44,0 +50,0 @@ var editor_class = self.getEditorClass(self.schema);

@@ -89,3 +89,3 @@ // Set the default theme

*/
error_maximum_incl: "Value must at most {{0}}",
error_maximum_incl: "Value must be at most {{0}}",
/**

@@ -173,2 +173,4 @@ * When a value is lesser than it's supposed to be (exclusive)

},
selectize: {
}

@@ -188,2 +190,7 @@ };

});
// If the type is not set but properties are defined, we can infer the type is actually object
JSONEditor.defaults.resolvers.unshift(function(schema) {
// If the schema is a simple type
if(!schema.type && schema.properties ) return "object";
});
// If the type is set and it's a basic type, use the primitive editor

@@ -202,3 +209,3 @@ JSONEditor.defaults.resolvers.unshift(function(schema) {

// Otherwise, default to select menu
return "select";
return (JSONEditor.plugins.selectize.enable) ? 'selectize' : 'select';
}

@@ -233,3 +240,3 @@ });

JSONEditor.defaults.resolvers.unshift(function(schema) {
if(schema.enumSource) return "select";
if(schema.enumSource) return (JSONEditor.plugins.selectize.enable) ? 'selectize' : 'select';
});

@@ -243,10 +250,17 @@ // Use the `enum` or `select` editors for schemas with enumerated properties

else if(schema.type === "number" || schema.type === "integer" || schema.type === "string") {
return "select";
return (JSONEditor.plugins.selectize.enable) ? 'selectize' : 'select';
}
}
});
// Use the 'multiselect' editor for arrays of enumerated strings/numbers/integers
// Specialized editors for arrays of strings
JSONEditor.defaults.resolvers.unshift(function(schema) {
if(schema.type === "array" && schema.items && !(Array.isArray(schema.items)) && schema.uniqueItems && schema.items["enum"] && ['string','number','integer'].indexOf(schema.items.type) >= 0) {
return 'multiselect';
if(schema.type === "array" && schema.items && !(Array.isArray(schema.items)) && schema.uniqueItems && ['string','number','integer'].indexOf(schema.items.type) >= 0) {
// For enumerated strings, number, or integers
if(schema.items.enum) {
return 'multiselect';
}
// For non-enumerated strings (tag editor)
else if(JSONEditor.plugins.selectize.enable && schema.items.type === "string") {
return 'arraySelectize';
}
}

@@ -253,0 +267,0 @@ });

@@ -183,2 +183,8 @@ // Multiple Editor (for when `type` is an array)

container.appendChild(this.editor_holder);
var validator_options = {};
if(self.jsoneditor.options.custom_validators) {
validator_options.custom_validators = self.jsoneditor.options.custom_validators;
}

@@ -204,3 +210,3 @@ this.switcher_options = this.theme.getSwitcherOptions(this.switcher);

self.validators[i] = new JSONEditor.Validator(self.jsoneditor,schema);
self.validators[i] = new JSONEditor.Validator(self.jsoneditor,schema,validator_options);
});

@@ -207,0 +213,0 @@

@@ -373,3 +373,2 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({

this.editor_holder = this.theme.getIndentedPanel();
this.editor_holder.style.paddingBottom = '0';
this.container.appendChild(this.editor_holder);

@@ -376,0 +375,0 @@

@@ -183,9 +183,16 @@ JSONEditor.defaults.editors.select = JSONEditor.AbstractEditor.extend({

var sanitized = val;
var new_val;
// Invalid option, use first option instead
if(this.enum_options.indexOf(val) === -1) {
sanitized = this.enum_options[0];
new_val = this.enum_values[0];
}
else {
new_val = this.enum_values[this.enum_options.indexOf(val)];
}
this.value = this.enum_values[this.enum_options.indexOf(val)];
// If valid hasn't changed
if(new_val === this.value) return;
// Store new value and propogate change event
this.value = new_val;
this.onChange(true);

@@ -204,2 +211,6 @@ },

});
this.select2.on('change',function() {
self.input.value = self.select2.select2('val');
self.onInputChange();
});
}

@@ -206,0 +217,0 @@ else {

@@ -1,6 +0,6 @@

/*! JSON Editor v0.7.22 - JSON Schema -> HTML Editor
/*! JSON Editor v0.7.23 - JSON Schema -> HTML Editor
* By Jeremy Dorn - https://github.com/jdorn/json-editor/
* Released under the MIT license
*
* Date: 2015-08-12
* Date: 2015-09-27
*/

@@ -7,0 +7,0 @@

@@ -51,2 +51,3 @@ JSONEditor.defaults.themes.bootstrap2 = JSONEditor.AbstractTheme.extend({

el.className = 'well well-small';
el.style.paddingBottom = 0;
return el;

@@ -53,0 +54,0 @@ },

@@ -64,2 +64,3 @@ JSONEditor.defaults.themes.bootstrap3 = JSONEditor.AbstractTheme.extend({

el.className = 'well well-sm';
el.style.paddingBottom = 0;
return el;

@@ -66,0 +67,0 @@ },

@@ -47,2 +47,3 @@ // Base Foundation theme

el.className = 'panel';
el.style.paddingBottom = 0;
return el;

@@ -49,0 +50,0 @@ },

JSONEditor.Validator = Class.extend({
init: function(jsoneditor,schema) {
init: function(jsoneditor,schema,options) {
this.jsoneditor = jsoneditor;
this.schema = schema || this.jsoneditor.schema;
this.options = {};
this.options = options || {};
this.translate = this.jsoneditor.translate || JSONEditor.defaults.translate;

@@ -511,6 +511,12 @@ },

// Custom type validation
// Custom type validation (global)
$each(JSONEditor.defaults.custom_validators,function(i,validator) {
errors = errors.concat(validator.call(self,schema,value,path));
});
// Custom type validation (instance specific)
if(this.options.custom_validators) {
$each(this.options.custom_validators,function(i,validator) {
errors = errors.concat(validator.call(self,schema,value,path));
});
}

@@ -517,0 +523,0 @@ return errors;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc