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.17 to 0.7.18

2

bower.json
{
"name": "json-editor",
"version": "0.7.17",
"version": "0.7.18",
"authors": [

@@ -5,0 +5,0 @@ "Jeremy Dorn <jeremy@jeremydorn.com>"

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

"description": "JSON Schema based editor",
"version": "0.7.17",
"version": "0.7.18",
"main": "dist/jsoneditor.js",

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

@@ -478,14 +478,14 @@ var JSONEditor = function(element,options) {

// extends schemas should be merged into parent
if(schema.extends) {
if(schema["extends"]) {
// If extends is a schema
if(!(Array.isArray(schema.extends))) {
extended = this.extendSchemas(extended,this.expandSchema(schema.extends));
if(!(Array.isArray(schema["extends"]))) {
extended = this.extendSchemas(extended,this.expandSchema(schema["extends"]));
}
// If extends is an array of schemas
else {
for(i=0; i<schema.extends.length; i++) {
extended = this.extendSchemas(extended,this.expandSchema(schema.extends[i]));
for(i=0; i<schema["extends"].length; i++) {
extended = this.extendSchemas(extended,this.expandSchema(schema["extends"][i]));
}
}
delete extended.extends;
delete extended["extends"];
}

@@ -492,0 +492,0 @@ // parent should be merged into oneOf schemas

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

JSONEditor.defaults.resolvers.unshift(function(schema) {
if(schema.enum) {
if(schema["enum"]) {
if(schema.type === "array" || schema.type === "object") {

@@ -245,3 +245,3 @@ return "enum";

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) {
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';

@@ -248,0 +248,0 @@ }

@@ -340,4 +340,4 @@ /**

getDefault: function() {
if(this.schema.default) return this.schema.default;
if(this.schema.enum) return this.schema.enum[0];
if(this.schema["default"]) return this.schema["default"];
if(this.schema["enum"]) return this.schema["enum"][0];

@@ -344,0 +344,0 @@ var type = this.schema.type || this.schema.oneOf;

JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
getDefault: function() {
return this.schema.default || [];
return this.schema["default"] || [];
},

@@ -171,3 +171,3 @@ register: function() {

title: schema.title || "item",
'default': schema.default,
'default': schema["default"],
width: 12,

@@ -298,3 +298,3 @@ child_editors: schema.properties || schema.items

while(value.length < this.schema.minItems) {
value.push(this.getItemInfo(value.length).default);
value.push(this.getItemInfo(value.length)["default"]);
}

@@ -301,0 +301,0 @@ }

// Enum Editor (used for objects and arrays with enumerated values)
JSONEditor.defaults.editors.enum = JSONEditor.AbstractEditor.extend({
JSONEditor.defaults.editors["enum"] = JSONEditor.AbstractEditor.extend({
getNumColumns: function() {

@@ -13,3 +13,3 @@ return 4;

this.enum = this.schema.enum;
this["enum"] = this.schema["enum"];
this.selected = 0;

@@ -20,5 +20,5 @@ this.select_options = [];

var self = this;
for(var i=0; i<this.enum.length; i++) {
for(var i=0; i<this["enum"].length; i++) {
this.select_options[i] = this.options.enum_titles[i] || "Value "+(i+1);
this.html_values[i] = this.getHTML(this.enum[i]);
this.html_values[i] = this.getHTML(this["enum"][i]);
}

@@ -44,10 +44,10 @@

self.selected = self.select_options.indexOf(this.value);
self.value = self.enum[self.selected];
self.value = self["enum"][self.selected];
self.refreshValue();
self.onChange(true);
});
this.value = this.enum[0];
this.value = this["enum"][0];
this.refreshValue();
if(this.enum.length === 1) this.switcher.style.display = 'none';
if(this["enum"].length === 1) this.switcher.style.display = 'none';
},

@@ -58,3 +58,3 @@ refreshValue: function() {

var stringified = JSON.stringify(this.value);
$each(this.enum, function(i, el) {
$each(this["enum"], function(i, el) {
if(stringified === JSON.stringify(el)) {

@@ -67,3 +67,3 @@ self.selected = i;

if(self.selected<0) {
self.setValue(self.enum[0]);
self.setValue(self["enum"][0]);
return;

@@ -70,0 +70,0 @@ }

@@ -10,3 +10,3 @@ JSONEditor.defaults.editors.multiselect = JSONEditor.AbstractEditor.extend({

var e = items_schema.enum || [];
var e = items_schema["enum"] || [];
this.option_keys = [];

@@ -93,2 +93,26 @@ for(i=0; i<e.length; i++) {

},
setupSelect2: function() {
if(window.jQuery && window.jQuery.fn && window.jQuery.fn.select2) {
var options = window.jQuery.extend({},JSONEditor.plugins.select2);
if(this.schema.options && this.schema.options.select2_options) options = $extend(options,this.schema.options.select2_options);
this.select2 = window.jQuery(this.input).select2(options);
var self = this;
this.select2.on('select2-blur',function() {
var val =self.select2.select2('val');
self.value = val;
self.onChange(true);
});
}
else {
this.select2 = null;
}
},
onInputChange: function() {
this.value = this.input.value;
this.onChange(true);
},
postBuild: function() {
this._super();
this.setupSelect2();
},
register: function() {

@@ -126,2 +150,3 @@ this._super();

this.value = new_value;
if(this.select2) this.select2.select2('val',this.value);
return changed;

@@ -151,2 +176,3 @@ },

}
if(this.select2) this.select2.select2("enable",true);
}

@@ -165,4 +191,12 @@ this._super();

}
if(this.select2) this.select2.select2("enable",false);
this._super();
},
destroy: function() {
if(this.select2) {
this.select2.select2('destroy');
this.select2 = null;
}
this._super();
}
});

@@ -1,2 +0,2 @@

JSONEditor.defaults.editors.null = JSONEditor.AbstractEditor.extend({
JSONEditor.defaults.editors["null"] = JSONEditor.AbstractEditor.extend({
getValue: function() {

@@ -3,0 +3,0 @@ return null;

JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
getDefault: function() {
return $extend({},this.schema.default || {});
return $extend({},this.schema["default"] || {});
},

@@ -176,2 +176,3 @@ getChildEditors: function() {

schema = $extend({},schema);
var matched = this.schema.properties[key]? true : false;

@@ -186,2 +187,3 @@ // Any matching patternProperties should be merged in

schema.allOf.push(this.schema.patternProperties[i]);
matched = true;
}

@@ -191,2 +193,7 @@ }

// Hasn't matched other rules, use additionalProperties schema
if(!matched && this.schema.additionalProperties && typeof this.schema.additionalProperties === "object") {
schema = $extend({},this.schema.additionalProperties);
}
return schema;

@@ -193,0 +200,0 @@ },

@@ -63,6 +63,6 @@ JSONEditor.defaults.editors.select = JSONEditor.AbstractEditor.extend({

// Enum options enumerated
if(this.schema.enum) {
if(this.schema["enum"]) {
var display = this.schema.options && this.schema.options.enum_titles || [];
$each(this.schema.enum,function(i,option) {
$each(this.schema["enum"],function(i,option) {
self.enum_options[i] = ""+option;

@@ -69,0 +69,0 @@ self.enum_display[i] = ""+(display[i] || option);

@@ -25,3 +25,3 @@ JSONEditor.defaults.editors.table = JSONEditor.defaults.editors.array.extend({

this.item_title = item_schema.title || 'row';
this.item_default = item_schema.default || null;
this.item_default = item_schema["default"] || null;
this.item_has_child_editors = item_schema.properties || item_schema.items;

@@ -98,3 +98,3 @@ this.width = 12;

getItemDefault: function() {
return $extend({},{default:this.item_default}).default;
return $extend({},{"default":this.item_default})["default"];
},

@@ -101,0 +101,0 @@ getItemTitle: function() {

@@ -5,3 +5,3 @@ JSONEditor.AbstractIconLib = Class.extend({

expand: '',
delete: '',
"delete": '',
edit: '',

@@ -8,0 +8,0 @@ add: '',

@@ -5,3 +5,3 @@ JSONEditor.defaults.iconlibs.bootstrap2 = JSONEditor.AbstractIconLib.extend({

expand: 'chevron-up',
delete: 'trash',
"delete": 'trash',
edit: 'pencil',

@@ -8,0 +8,0 @@ add: 'plus',

@@ -5,3 +5,3 @@ JSONEditor.defaults.iconlibs.bootstrap3 = JSONEditor.AbstractIconLib.extend({

expand: 'chevron-right',
delete: 'remove',
"delete": 'remove',
edit: 'pencil',

@@ -8,0 +8,0 @@ add: 'plus',

@@ -5,3 +5,3 @@ JSONEditor.defaults.iconlibs.fontawesome3 = JSONEditor.AbstractIconLib.extend({

expand: 'chevron-right',
delete: 'remove',
"delete": 'remove',
edit: 'pencil',

@@ -8,0 +8,0 @@ add: 'plus',

@@ -5,3 +5,3 @@ JSONEditor.defaults.iconlibs.fontawesome4 = JSONEditor.AbstractIconLib.extend({

expand: 'caret-square-o-right',
delete: 'times',
"delete": 'times',
edit: 'pencil',

@@ -8,0 +8,0 @@ add: 'plus',

@@ -5,3 +5,3 @@ JSONEditor.defaults.iconlibs.foundation2 = JSONEditor.AbstractIconLib.extend({

expand: 'plus',
delete: 'remove',
"delete": 'remove',
edit: 'edit',

@@ -8,0 +8,0 @@ add: 'add-doc',

@@ -5,3 +5,3 @@ JSONEditor.defaults.iconlibs.foundation3 = JSONEditor.AbstractIconLib.extend({

expand: 'plus',
delete: 'x',
"delete": 'x',
edit: 'pencil',

@@ -8,0 +8,0 @@ add: 'page-add',

@@ -5,3 +5,3 @@ JSONEditor.defaults.iconlibs.jqueryui = JSONEditor.AbstractIconLib.extend({

expand: 'triangle-1-e',
delete: 'trash',
"delete": 'trash',
edit: 'pencil',

@@ -8,0 +8,0 @@ add: 'plusthick',

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

/*! JSON Editor v0.7.17 - JSON Schema -> HTML Editor
/*! JSON Editor v0.7.18 - JSON Schema -> HTML Editor
* By Jeremy Dorn - https://github.com/jdorn/json-editor/
* Released under the MIT license
*
* Date: 2015-03-07
* Date: 2015-05-09
*/

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

@@ -1,2 +0,2 @@

JSONEditor.defaults.templates.default = function() {
JSONEditor.defaults.templates["default"] = function() {
var expandVars = function(vars) {

@@ -3,0 +3,0 @@ var expanded = {};

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

el.className = 'help-block';
el.textContent = text;
el.innerHTML = text;
return el;

@@ -72,0 +72,0 @@ },

@@ -0,4 +1,19 @@

/**
* Taken from jQuery 1
*
* @param obj
* @returns {*}
*/
var $isplainobject = function( obj ) {
var key;
// Must be an Object.
// Because of IE, we also have to check the presence of the constructor property.
// Make sure that DOM nodes and window objects don't pass through, as well
if ( !obj || typeof obj !== "object" || obj.nodeType || obj === window ) {
return false;
}
// Not own constructor property must be Object
if ( obj.constructor &&
if (obj.constructor &&
!obj.hasOwnProperty('constructor') &&

@@ -9,8 +24,25 @@ !obj.constructor.prototype.hasOwnProperty('isPrototypeOf')) {

try {
// Not own constructor property must be Object
if ( obj.constructor &&
!obj.hasOwnProperty("constructor") &&
!obj.constructor.prototype.hasOwnProperty('isPrototypeOf') ) {
return false;
}
} catch ( e ) {
// IE8,9 Will throw exceptions on certain host objects #9897
return false;
}
// Support: IE<9
// Handle iteration over inherited properties before own properties.
if ( /msie 8\.0/i.test( window.navigator.userAgent ) ) {
for ( key in obj ) {
return obj.hasOwnProperty(key);
}
}
// Own properties are enumerated firstly, so to speed up,
// if last one is own, then all properties are own.
var key;
for ( key in obj ) {}
return key === undefined || obj.hasOwnProperty(key);

@@ -17,0 +49,0 @@ };

@@ -12,2 +12,3 @@ JSONEditor.Validator = Class.extend({

_validateSchema: function(schema,value,path) {
var self = this;
var errors = [];

@@ -56,6 +57,6 @@ var valid, i, j;

// `enum`
if(schema.enum) {
if(schema["enum"]) {
valid = false;
for(i=0; i<schema.enum.length; i++) {
if(stringified === JSON.stringify(schema.enum[i])) valid = true;
for(i=0; i<schema["enum"].length; i++) {
if(stringified === JSON.stringify(schema["enum"][i])) valid = true;
}

@@ -72,5 +73,5 @@ if(!valid) {

// `extends` (version 3)
if(schema.extends) {
for(i=0; i<schema.extends.length; i++) {
errors = errors.concat(this._validateSchema(schema.extends[i],value,path));
if(schema["extends"]) {
for(i=0; i<schema["extends"].length; i++) {
errors = errors.concat(this._validateSchema(schema["extends"][i],value,path));
}

@@ -515,3 +516,3 @@ }

$each(JSONEditor.defaults.custom_validators,function(i,validator) {
errors = errors.concat(validator(schema,value,path));
errors = errors.concat(validator.call(self,schema,value,path));
});

@@ -518,0 +519,0 @@

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

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

Sorry, the diff of this file is not supported yet

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